Trailer header
The HTTP Trailer {{glossary("request header", "request")}} and {{glossary("response header")}}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]NOTE: The{{HTTPHeader("TE")}}TE request header needs to be set totrailersto allow trailer fields.
[!WARNING]WARNING: Developers cannot access HTTP trailers via the Fetch API or XHR. Additionally, browsers ignore HTTP trailers, with the exception of{{HTTPHeader("Server-Timing")}}Timing. See Browser compatibility for more information.
| Header type |
|
|---|---|
| Yes |
Syntax
Trailer: header-names
Directives
header-names- : HTTP header fields which will be present in the trailer part of chunked messages.
The following header names are disallowed:
{{HTTPHeader("Content-Encoding")}}Encoding,{{HTTPHeader("Content-Type")}}Type,{{HTTPHeader("Content-Range")}}Range, andTrailer- Authentication headers (e.g.,
{{HTTPHeader("Authorization")}}Authorization or{{HTTPHeader("Set-Cookie")}}Cookie) - Message framing headers (e.g.,
{{HTTPHeader("Transfer-Encoding")}}Encoding and{{HTTPHeader("Content-Length")}}Length) - Routing headers (e.g.,
{{HTTPHeader("Host")}}Host) - Request modifiers (e.g., controls and conditionals, like
{{HTTPHeader("Cache-Control")}}Control,{{HTTPHeader("Max-Forwards")}}Forwards, or{{HTTPHeader("TE")}}TE)
- : HTTP header fields which will be present in the trailer part of chunked messages.
The following header names are disallowed:
Examples
Server-Timing as HTTP trailer
Some browsers support showing server timing data in developer tools when the {{HTTPHeader("Server-Timing")}}Timing header is sent as a trailer.
In the following response, the Trailer header is used to indicate 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
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
{{HTTPHeader("Server-Timing")}}Timing{{HTTPHeader("Transfer-Encoding")}}Encoding{{HTTPHeader("TE")}}TE- Chunked transfer encoding