Draft
Conversation
This document outlines the comprehensive plan for implementing HTTP trailers support in @fastify/reply-from, including: - Architecture design for trailer collection across HTTP/1.1, HTTP/2, and undici clients - Plugin integration with new configuration options and hooks - Security considerations with forbidden trailer filtering - Comprehensive testing strategy and timeline - Backward-compatible implementation approach 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Adds foundation for trailer collection across all HTTP clients: - HTTP/1.1: Collect trailers on response 'end' event - HTTP/2: Listen for 'trailers' event on stream - Undici: Use built-in trailers property from response - New utility functions for trailer filtering and client capability detection - Comprehensive unit tests for trailer utilities All HTTP clients now return getTrailers() accessor function in response object. Trailer functionality is backward compatible and follows RFC 7230/9110 specifications. Establishes the foundation for trailer forwarding without breaking existing functionality.
Adds complete trailer forwarding capability with plugin integration: **Configuration Options:** - `forwardTrailers` - Enable/disable trailer forwarding (default: true) - `stripForbiddenTrailers` - Remove RFC-forbidden trailer fields (default: true) - `requireTrailerSupport` - Only forward if client advertises support (default: false) - `trailersTimeout` - Timeout for trailer collection (default: 5s) - `maxTrailerSize` - Size limit for trailer data (default: 8KB) **Request/Response Hooks:** - `rewriteTrailers(trailers, request)` - Transform upstream trailers - `onTrailers(request, reply, trailers)` - Custom trailer handling - `addTrailers` - Add custom trailers (static values or async functions) **Features:** - Automatic trailer forwarding from upstream servers to clients - RFC 7230/9110 compliant security filtering - Timeout protection for trailer collection - Size limits to prevent memory exhaustion - Comprehensive error handling and logging **Tests:** - Integration tests for all trailer forwarding scenarios - Configuration option validation - Hook functionality verification - Size limit and timeout protection tests Maintains backward compatibility with existing functionality.
03dcc3f to
002859e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements comprehensive HTTP trailers support for
@fastify/reply-from, enabling automatic forwarding of HTTP trailers from upstream servers to clients across all supported HTTP protocols.Key Features
🏗️ Core Infrastructure
⚙️ Configuration Options
forwardTrailers- Enable/disable trailer forwarding (default: true)stripForbiddenTrailers- Remove forbidden trailer fields (default: true)requireTrailerSupport- Only forward when client advertises support (default: false)trailersTimeout- Timeout for trailer collection (default: 5s)maxTrailerSize- Size limit for trailer data (default: 8KB)🎯 Request/Response Hooks
rewriteTrailers(trailers, request)- Transform upstream trailers before forwardingonTrailers(request, reply, trailers)- Custom trailer handling logicaddTrailers- Add custom trailers (static values or async functions)Implementation Details
Automatic Trailer Forwarding: Trailers from upstream servers are automatically collected and forwarded to clients while respecting RFC specifications and security requirements.
Security & Performance:
Multi-Protocol Support: Works seamlessly across HTTP/1.1, HTTP/2, and Undici clients with protocol-specific optimizations.
Usage Examples
Test Coverage
Backward Compatibility
Fully backward compatible - all trailer functionality is opt-in and defaults to enabled for seamless adoption.
Related
Implements the comprehensive plan outlined in
TRAILERS.md