Transfer-Encoding

The HTTP Transfer-Encoding header indicates the encoding method used to transfer the message body between entities.

Usage

The HTTP Transfer-Encoding header is a hop-by-hop header that is used between any two nodes. It indicates the encoding method used for the message body in the current transmission. Different Transfer-Encoding methods may be used between nodes.

In cases where the HTTP Transfer-Encoding header is included in the response to an HTTP HEAD request, the Transfer-Encoding refers to the encoding to be applied to the message body had the request been HTTP GET instead.

Note

The HTTP Transfer-Encoding header is not used in HTTP/2.

The Transfer-Encoding directives are chunked, compress, deflate, and gzip. Directives can be included using separate HTTP headers or included on the same line in a comma-delimited format.

chunked

The chunked directive implies that the client supports trailer fields in a chunked transfer encoding.

compress

The compress directive uses the Lempel-Ziv-Welch (LZW) compression algorithm.

deflate

The deflate directive uses a zlib structure to compress data.

gzip

The gzip directive uses a Lempel-Zif encoding method and maintains a 32-bit CRC.

Example

In this example, the compress directive is used.

Transfer-Encoding: compress

End-to-End encoding

Rather than specifying the encoding between individual nodes, it is possible to specify the encoding for the entire message between the client and the server. However, this requires the use of the HTTP Content-Encoding header.

Takeaway

The HTTP Transfer-Encoding header is used to indicate what encoding methods are used for the current message and refers only to the connection between two nodes on a hop-by-hop basis.

See also

Last updated: June 2, 2022