Transfer-Encoding Header

The Transfer-Encoding header specifies the form of encoding used to safely transfer the entity over the network. It is applied to the message during transmission between two nodes, and not to the resource itself.

Transfer-Encoding is primarily intended to accurately delimit and safely transfer a dynamically generated payload.

The mostly used Transfer-Encoding method is chunked transfer encoding. For example, servers may use chunked encoding when they need to send a large amount of data, or the total length of the data is unknown.

When chunked transfer encoding is used, the data stream is divided into a series of non-overlapping chunks. Each chunk is sent and received independently of each other and is preceded by its own size in bytes.

No knowledge of the data stream outside the currently-being-processed chunk is required by either the sender or the receiver at any given time. Transmission ends when a zero-length chunk is received.

Server Response with Chunked Transfer Encoding Header
HTTP/1.0 200 OK 
Content-Type: text/plain 
Transfer-Encoding: chunked

Http Client\r\n

Transfer-Encoding Directives

  • chunked: data is sent in series of non-overlapping chunks.
  • gzip: GNU zip format uses the deflate algorithm for compression.
  • deflate: compression based on the deflate algorithm.
  • compress: UNIX "compress" program method, deprecated and replaced by gzip or deflate

Many older HTTP/1.0 applications do not support the Transfer-Encoding header. Also, the Transfer-Encoding header must not be used with HTTP/2.
http-headers transfer-encoding server-response