HTTP Headers
Trailer
The HTTP Trailer request and response header allow the sender to include additional fields at the end of chunked messages to provide metadata that might be generated dynamically while the message body is transmitted.
Warning:
Developers cannot access HTTP trailers via the Fetch API or XMLHttpRequest.
Additionally, browsers ignore HTTP trailers, except for Server-Timing
.
Refer to Browser compatibility for more details.
Header type | Request header, Response header, Content header |
---|---|
Forbidden request header | Yes |
Syntax
Trailer: header-names
Directives
Directives
- header-names
- HTTP header fields that are included in the trailer part of chunked messages.
The following header names are not allowed in the trailer:
- Content-Encoding, Content-Type, Content-Range, and
Trailer
- Content-Encoding, Content-Type, Content-Range, and
- Authentication headers, such as Authorization or Set-Cookie
- Message framing headers, like Transfer-Encoding and Content-Length
- Routing headers, for example Host
- Request modifiers, including controls and conditionals like Cache-Control, Max-Forwards, or TE
Example
Server-Timing as HTTP trailer
Some browsers support displaying server timing information in developer tools when the Server-Timing header is transmitted as a trailer.
In the following response, the Trailer header signals that a Server-Timing header will follow the response body.
A metric custom-metric with a duration of 123.4 milliseconds is sent:
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Trailer: Server-Timing
--- response body ---
Server-Timing: custom-metric;dur=123.4
How to Modify Header using Requestly
Requestly is a powerful Chrome extension that allows you to modify HTTP headers, including the Trailer header. This is especially useful for testing how your servers handle trailing headers, which can be important for streaming or chunked responses.
Steps to Modify the Trailer Header:
- Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
- Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
- Add a new header modification:
- Under “Action”, select “Add” or “Override”.
- In the “Header Name” field, enter Trailer.
- In the “Header Value” field, enter the trailer header name(s) you want to include (e.g., Expires, Content-MD5).
- Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/*).
- Save the rule.
Once set up, Requestly will inject the Trailer header into all matching requests, letting you test how your application or server deals with trailing headers often used in chunked HTTP transfers.
Table of Contents
- No headings found.