🎉 Requestly joins BrowserStack to build the future of application testing. Read more

HTTP Headers

Trailer

HTTP Header

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 typeRequest header,
Response header,
Content header
Forbidden request headerYes

Syntax

The syntax involves specifying the trailer header in an HTTP message. The format is as follows:
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
    • 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:

  1. Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
  2. Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
  3. 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).
  4. Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/*).
  5. 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.