Transfer-Encoding
ResponseActiveThe Transfer-Encoding header specifies how the response body is encoded for transfer between nodes. The most important value is 'chunked' – the server sends the body in a series of chunks without needing to know the total Content-Length upfront. This enables streaming responses. Transfer-Encoding is a hop-by-hop header, unlike Content-Encoding which is end-to-end.
Transfer-Encoding: chunked | compress | deflate | gzip | identity
Description
Transfer-Encoding controls how the message body is framed for transfer. 'chunked' encoding allows the server to send data in pieces as it becomes available, each prefixed with its size in hexadecimal. This is essential for streaming large responses or when the total size isn't known ahead of time. Transfer-Encoding is removed by each proxy that processes it.
Directives
| Directive | Description |
|---|---|
| chunked | Body sent in hex-prefixed chunks. Each chunk: <size>\r\n<data>\r\n. Terminated by 0\r\n\r\n. |
| gzip | Body compressed with gzip. Rare – use Content-Encoding: gzip instead. |
| identity | No transformation (default). Rarely sent explicitly. |
Examples
Chunked response
http
HTTP/1.1 200 OK
Transfer-Encoding: chunked
7
Hello,
6
world!
0Streaming API
http
HTTP/1.1 200 OK
Content-Type: text/event-stream
Transfer-Encoding: chunked