The HTTP Transfer-Encoding is a response-type header that performs as the hop-by-hop header, the hop-by-hop header connection is the single transport-level connection must not be re-transmitted. This header is performing between two nodes (single transport-level connection). If there is multi-node connection then have to use other
Transfer-Encoding values. There is an end-to-end
Content-Encoding header that can be use to compress the data over the whole connection.
Transfer-Encoding: chunked | compress | deflate | gzip | identity
Directives: This header accepts five directives mentioned above and described below:
- chunked: This directive is used to send the series of data in a chunk format, but have to mentioned the length of each chunk before sending the chunk of the data in hexadecimal format like
'\r\n'and then the chunk itself, followed by another
- compress: It is a compression format using the Lempel-Ziv-Welch (LZW) algorithm.
- deflate: It is a compression format using the zlib structure, with the deflate compression algorithm.
- gzip: It is a compression format using the Lempel-Ziv coding (LZ77), with a 32-bit CRC.
- identity: This directive Indicates the identity function which is always acceptable.
Note: The terminating chunks are the regular chunks, length of those chunks by default zero.
Example: The chunk encoding for this header is useful when the server sending the huge amount of series of data to the client. The total size of the response may be unknown until the request has been completed. Suppose there is a large amount of data from a database query, a chunked response looks like this
HTTP/1.0 200 OK Content-Type: text/plain Transfer-Encoding: chunked 0\r\n Mozilla\r\n 7\r\n Developer\r\n 9\r\n Network\r\n 0\r\n \r\n
To check this Transfer-Encoding in action go to Inspect Element -> Network check the request header for Transfer-Encoding like below, Transfer-Encoding is highlighted you can see.
Supported Browsers: The browsers are compatible with HTTP Transfer-Encoding header are listed below:
- Google Chrome
- Internet Explorer
- HTTP headers | Access-Control-Expose-Headers
- HTTP headers | Access-Control-Allow-Headers.
- HTTP headers | Access-Control-Request-Headers
- HTTP headers | Location
- HTTP headers | User-Agent
- HTTP headers | Link
- HTTP headers | Save-Data
- HTTP headers | Content-Type
- HTTP headers | X-XSS-Protection
- HTTP headers | X-Frame-Options
- HTTP headers | Last-Modified
- HTTP headers | Date
- HTTP headers | Cookie
- HTTP headers | Strict-Transport-Security
- HTTP headers | Expect
- HTTP headers | Accept-Encoding
- HTTP headers | Proxy-Authenticate
- HTTP headers | Content-Range
- HTTP headers | Content-Encoding
- HTTP headers | Content-Language
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.