Skip to main content

Transfer-Encoding

ResponseActive

The 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

DirectiveDescription
chunkedBody sent in hex-prefixed chunks. Each chunk: <size>\r\n<data>\r\n. Terminated by 0\r\n\r\n.
gzipBody compressed with gzip. Rare – use Content-Encoding: gzip instead.
identityNo transformation (default). Rarely sent explicitly.

Examples

Chunked response
http
HTTP/1.1 200 OK
Transfer-Encoding: chunked

7
Hello, 
6
world!
0
Streaming API
http
HTTP/1.1 200 OK
Content-Type: text/event-stream
Transfer-Encoding: chunked

Related

Specification

RFC 9112Transfer-Encoding specification →