HTTP trailers: handle metadata that arrives after the body
An HTTP trailer is a field delivered after the message content. It can carry values that are only available while sending the body, such as a digest or post-processing status. Intermediaries may discard trailers, so do not put essential control information or required results only there. Send a field as a trailer only when its definition permits it, and do not treat delayed validation as complete before the trailer arrives.
An HTTP trailer is a field delivered after the message content. It can carry values that are only available while sending the body, such as a digest or post-processing status. Intermediaries may discard trailers, so do not put essential control information or required results only there. Send a field as a trailer only when its definition permits it, and do not treat delayed validation as complete before the trailer arrives.
What makes a trailer different?
The header section arrives before the content; the trailer section follows it. This makes trailers useful for metadata computed during streaming. RFC 9110 gives integrity checks, signatures, delivery metrics, and post-processing status as examples. Process and store trailers separately from headers. (RFC 9110 §6.5)
In HTTP/1.1, a trailer may follow the final zero-length chunk of a chunked message. In HTTP/2, trailers are carried in the final field block that ends the stream. The semantics are similar, but the wire framing differs; HTTP/2 does not use HTTP/1.1's Transfer-Encoding: chunked syntax. (RFC 9112 §7.1.2, RFC 9113 §4.3)
When may a field be sent as a trailer?
Only when the field specification says trailer use is allowed. Content-Digest, which can be calculated over the received content, is one example permitted by RFC 9530. (RFC 9530 §2.1, §6.4)
Do not defer values needed for framing, routing, authentication, request modification, response control, or content format. Examples include Content-Length, Host, Authorization, and Content-Type. Listing a field in the Trailer header does not make an otherwise unsuitable field safe to defer.
Proxies and gateways can discard trailers when translating protocols. TE: trailers indicates willingness not to discard them; it does not guarantee that every intermediary will preserve or process a particular field. Never make a user-critical operation or security decision depend only on a trailer. (RFC 9110 §6.5.1, §10.1.4)
HTTP/1.1 example
This illustrates the wire format; verify trailer support in the actual client, server, and proxy path.
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Transfer-Encoding: chunked
Trailer: Content-Digest
<chunked body bytes>
0
Content-Digest: sha-256=:BASE64_DIGEST_VALUE:The receiver can compare the digest with a value computed from the content. If validation matters, do not trust or persist the data before the digest arrives and passes; define what happens when it is missing or mismatched. A matching digest verifies a hash of the content, but does not by itself authenticate who sent it or make the whole transport path trustworthy.
Implementation checklist
Confirm that the field's specification permits trailer use.
Check the HTTP version and library API. HTTP/1.1 chunked bodies and HTTP/2 or HTTP/3 ending field sections have different wire formats.
Verify trailer preservation across the real proxy, gateway, and CDN path; do not infer end-to-end support from configuration alone.
Define safe behavior for missing, late, or invalid trailers. Do not rely only on a trailer for required metadata.
Decide whether a streaming consumer may use content before trailer validation; avoid irreversible side effects before validation when the threat model requires it.
Trailers are optional metadata for values known only after the content. They do not replace ordinary headers, and intermediaries are not guaranteed to preserve them.
References
[RFC 9110: HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110.html)
[RFC 9112: HTTP/1.1](https://www.rfc-editor.org/rfc/rfc9112.html)
[RFC 9113: HTTP/2](https://www.rfc-editor.org/rfc/rfc9113.html)
[RFC 9530: Digest Fields](https://www.rfc-editor.org/rfc/rfc9530.html)