Trailer header
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The HTTPTrailerrequest andresponse header allows the sender to include additional fields at the end of chunked messages in order to supply metadata that might be dynamically generated while the message body is sent.
Note:TheTE request header needs to be set totrailers to allow trailer fields.
Warning:Developers cannot access HTTP trailers via the Fetch API or XHR.Additionally, browsers ignore HTTP trailers, with the exception ofServer-Timing.SeeBrowser compatibility for more information.
In this article
Syntax
Trailer: header-namesDirectives
header-namesHTTP header fields which will be present in the trailer part of chunked messages.The following header names aredisallowed:
Content-Encoding,Content-Type,Content-Range, andTrailer- Authentication headers (e.g.,
AuthorizationorSet-Cookie) - Message framing headers (e.g.,
Transfer-EncodingandContent-Length) - Routing headers (e.g.,
Host) - Request modifiers (e.g., controls and conditionals, like
Cache-Control,Max-Forwards, orTE)
Examples
>Server-Timing as HTTP trailer
Some browsers support showing server timing data in developer tools when theServer-Timing header is sent as a trailer.In the following response, theTrailer header is used to indicate that aServer-Timing header will follow the response body.A metriccustom-metric with a duration of123.4 milliseconds is sent:
HTTP/1.1 200 OKTransfer-Encoding: chunkedTrailer: Server-Timing--- response body ---Server-Timing: custom-metric;dur=123.4Specifications
| Specification |
|---|
| HTTP Semantics> # field.trailer> |
| HTTP/1.1> # chunked.trailer.section> |