What is the TE header?
The TE request header, defined in Section 10.1.4 of RFC 9110, describes the client’s capabilities for transfer codings and trailer sections. Its value is a list of members:
trailerssays the client will not discard trailer fields, on behalf of itself and any downstream clients. It does not promise any particular trailer will be processed, only that the trailer section will not be dropped.- A transfer coding name, with an optional weight and parameters, says the client can accept that transfer coding in the response. Only HTTP/1.1 uses transfer codings, and
chunkedis never listed: it is always acceptable to an HTTP/1.1 recipient, and RFC 9112 says a client MUST NOT send it inTE.
TE: trailersTE is hop-by-hop. A sender MUST also list TE in the Connection header so intermediaries do not forward it. In HTTP/2 it is the one connection-specific field allowed in a request, and only with the value trailers; RFC 9113 says it MUST NOT contain anything else.
API Usage & Best Practices
- Send
TE: trailersif you need trailers. A server that wants to put a checksum, a signature or a final status after a streamed body has no way to know the client will keep it unless the client says so. RFC 9110 tells servers not to generate trailers they believe the client must receive, because they can be discarded in transit. SeeTrailer. - gRPC requires it. The gRPC over HTTP/2 protocol has clients send
te: trailers, which its specification says is used to detect incompatible proxies. gRPC carries its status in trailers, so every proxy in front of a gRPC service has to pass them through. See gRPC. - Do not use it for compression. Transfer codings such as
gzipinTEare an HTTP/1.1-only, hop-by-hop mechanism. For APIs, compression is negotiated withAccept-EncodingandContent-Encoding. - Never send other values over HTTP/2. Anything other than
trailersin an HTTP/2 request is a malformed request. - Browsers set it, not scripts.
TEis a forbidden request header in the Fetch standard, so browser JavaScript cannot set it. - Forward it correctly in proxies. As a hop-by-hop field, it is not passed on as-is. When an intermediary sends
TE: trailers, RFC 9110 reads it as a promise on behalf of every downstream client, so only send it upstream if the trailers will actually reach them.
Examples
An HTTP/1.1 client that accepts trailers, with the required Connection option:
GET /v1/exports/exp_9f2/download HTTP/1.1Host: api.example.comTE: trailersConnection: TEThe request headers of a gRPC call over HTTP/2, shown as HTTP/2 fields:
:method = POST:scheme = https:path = /orders.v1.OrderService/GetOrder:authority = api.example.comcontent-type = application/grpcte = trailers