Skip to content

Transfer-Encoding: chunked vs Content-Length

The Content-Length header determines the byte length of the request/response body. If you neglect to specify the Content-Length header, HTTP servers will implicitly add a Transfer-Encoding: chunked header.

Transfer-Encoding: chunked

The Transfer-Encoding header specifies the form of encoding used to transfer messages between nodes on the network.

Syntax

Transfer-Encoding: chunked
Transfer-Encoding: compress
Transfer-Encoding: deflate
Transfer-Encoding: gzip

// Several values can be listed, separated by a comma
Transfer-Encoding: gzip, chunked
Transfer-Encoding: chunked
Transfer-Encoding: compress
Transfer-Encoding: deflate
Transfer-Encoding: gzip

// Several values can be listed, separated by a comma
Transfer-Encoding: gzip, chunked

chunked

Data is sent in a series of chunks.

At the beginning of each chunk you need to add the length of the current chunk in hexadecimal format, followed by \r\n and then the chunk itself, followed by another \r\n.

The terminating chunk is a regular chunk, with the exception that its length is zero.

Example

HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cache-Control: no-store, no-cache, must-revalidate
Connection: keep-alive
Content-Security-Policy: default-src 'self' http://*.hotjar.com:* https://*.hotjar.com:* http://*.hotjar.io https://*.hotjar.io wss://*.hotjar.com; frame-src 'self' *.facebook.com *.youtube.com *.google.com *.hotjar.com https://*.hotjar.com http://*.hotjar.io https://*.hotjar.io; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.google.com *.gstatic.com *.googletagmanager.com *.facebook.net *.licdn.com *.google-analytics.com *.googleadservices.com trackcmp.net *.youtube.com *.ytimg.com *.app-us1.com *.adroll.com *.hotjar.com *.consensu.org http://*.hotjar.com https://*.hotjar.com http://*.hotjar.io https://*.hotjar.io; style-src 'self' 'unsafe-inline' https://fonts.gstatic.com unpkg.com *.googleapis.com; font-src 'self' https://fonts.gstatic.com data: *.googleapis.com http://*.hotjar.com https://*.hotjar.com http://*.hotjar.io https://*.hotjar.io; img-src * ; connect-src 'self' ipinfo.io stealthtalk.com *.stealthtalk.com *.hotjar.com http://*.hotjar.com:* https://*.hotjar.com:* http://*.hotjar.io https://*.hotjar.io wss://*.hotjar.com; child-src www.youtube.com
Content-Security-Policy: connect-src: https://analytics.google.com https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com; script-src: https://*.googletagmanager.com; img-src: https://*.google-analytics.com https://*.googletagmanager.com;
Content-Type: application/json; charset=UTF-8
Date: Fri, 20 Sep 2024 01:53:44 GMT
Feature-Policy: unsized-media 'none'; camera 'none'; microphone 'none'; payment 'none'
Keep-Alive: timeout=30
Referrer-Policy: no-referrer-when-downgrade
Server: nginx
Strict-Transport-Security: max-age=31536000;
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Powered-By: PHP/7.4.7
X-Xss-Protection: 1

2ec
{"applinks":{"details":[{"appIDs":["Z6QR6VJL79.com.stealthtalk.client"],"components":[{"/":"/deep-link/create_enterprise_account","?":{"enterprise_id":"?*"},"comment":"App link for creating enterprise account. enteprise_id required"},{"/":"/testers/create_enterprise_account","exclude":true,"comment":"Stage appp link for creating enterprise account. Blocked for consume app."}]},{"appIDs":["Z6QR6VJL79.com.stealthtalk.client.debug"],"components":[{"/":"/testers/create_enterprise_account","?":{"enterprise_id":"?*"},"comment":"Stage app link for creating enterprise account. enteprise_id required"},{"/":"/deep-link/create_enterprise_account","exclude":true,"comment":"App link for creating enterprise account. Blocked for stage application"}]}]}}
0
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cache-Control: no-store, no-cache, must-revalidate
Connection: keep-alive
Content-Security-Policy: default-src 'self' http://*.hotjar.com:* https://*.hotjar.com:* http://*.hotjar.io https://*.hotjar.io wss://*.hotjar.com; frame-src 'self' *.facebook.com *.youtube.com *.google.com *.hotjar.com https://*.hotjar.com http://*.hotjar.io https://*.hotjar.io; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.google.com *.gstatic.com *.googletagmanager.com *.facebook.net *.licdn.com *.google-analytics.com *.googleadservices.com trackcmp.net *.youtube.com *.ytimg.com *.app-us1.com *.adroll.com *.hotjar.com *.consensu.org http://*.hotjar.com https://*.hotjar.com http://*.hotjar.io https://*.hotjar.io; style-src 'self' 'unsafe-inline' https://fonts.gstatic.com unpkg.com *.googleapis.com; font-src 'self' https://fonts.gstatic.com data: *.googleapis.com http://*.hotjar.com https://*.hotjar.com http://*.hotjar.io https://*.hotjar.io; img-src * ; connect-src 'self' ipinfo.io stealthtalk.com *.stealthtalk.com *.hotjar.com http://*.hotjar.com:* https://*.hotjar.com:* http://*.hotjar.io https://*.hotjar.io wss://*.hotjar.com; child-src www.youtube.com
Content-Security-Policy: connect-src: https://analytics.google.com https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com; script-src: https://*.googletagmanager.com; img-src: https://*.google-analytics.com https://*.googletagmanager.com;
Content-Type: application/json; charset=UTF-8
Date: Fri, 20 Sep 2024 01:53:44 GMT
Feature-Policy: unsized-media 'none'; camera 'none'; microphone 'none'; payment 'none'
Keep-Alive: timeout=30
Referrer-Policy: no-referrer-when-downgrade
Server: nginx
Strict-Transport-Security: max-age=31536000;
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Powered-By: PHP/7.4.7
X-Xss-Protection: 1

2ec
{"applinks":{"details":[{"appIDs":["Z6QR6VJL79.com.stealthtalk.client"],"components":[{"/":"/deep-link/create_enterprise_account","?":{"enterprise_id":"?*"},"comment":"App link for creating enterprise account. enteprise_id required"},{"/":"/testers/create_enterprise_account","exclude":true,"comment":"Stage appp link for creating enterprise account. Blocked for consume app."}]},{"appIDs":["Z6QR6VJL79.com.stealthtalk.client.debug"],"components":[{"/":"/testers/create_enterprise_account","?":{"enterprise_id":"?*"},"comment":"Stage app link for creating enterprise account. enteprise_id required"},{"/":"/deep-link/create_enterprise_account","exclude":true,"comment":"App link for creating enterprise account. Blocked for stage application"}]}]}}
0

The 2ec is the content length in hexadecimal. 0x2ec is equal to 748 in decimal.

The extra 0 is the length of terminating chunk.

Content-Length

HTTP/1.1 200 OK
Content-Length: 748
Age: 5
Apple-From: https://stealthtalk.com/.well-known/apple-app-site-association
Apple-Origin-Format: json
Cache-Control: max-age=21600,public
Cdnuuid: 39e3027c-be92-4091-a675-1c5863da3027-884280677
Connection: keep-alive
Content-Type: application/json
Date: Fri, 20 Sep 2024 01:53:45 GMT
Via: https/1.1 jptyo12-3p-pst-007.ts.apple.com (acdn/255.14450), https/1.1 jptyo12-3p-pac-007.ts.apple.com (acdn/255.14450), https/1.1 jptyo12-3p-pfe-013.ts.apple.com (acdn/255.14450), https/1.1 jptyo5-edge-lx-011.ts.apple.com (acdn/255.14450), https/1.1 jptyo5-edge-bx-018.ts.apple.com (acdn/255.14450)
X-Cache: hit-stale, hit-stale, miss, miss, miss

{"applinks":{"details":[{"appIDs":["Z6QR6VJL79.com.stealthtalk.client"],"components":[{"/":"/deep-link/create_enterprise_account","?":{"enterprise_id":"?*"},"comment":"App link for creating enterprise account. enteprise_id required"},{"/":"/testers/create_enterprise_account","exclude":true,"comment":"Stage appp link for creating enterprise account. Blocked for consume app."}]},{"appIDs":["Z6QR6VJL79.com.stealthtalk.client.debug"],"components":[{"/":"/testers/create_enterprise_account","?":{"enterprise_id":"?*"},"comment":"Stage app link for creating enterprise account. enteprise_id required"},{"/":"/deep-link/create_enterprise_account","exclude":true,"comment":"App link for creating enterprise account. Blocked for stage application"}]}]}}
HTTP/1.1 200 OK
Content-Length: 748
Age: 5
Apple-From: https://stealthtalk.com/.well-known/apple-app-site-association
Apple-Origin-Format: json
Cache-Control: max-age=21600,public
Cdnuuid: 39e3027c-be92-4091-a675-1c5863da3027-884280677
Connection: keep-alive
Content-Type: application/json
Date: Fri, 20 Sep 2024 01:53:45 GMT
Via: https/1.1 jptyo12-3p-pst-007.ts.apple.com (acdn/255.14450), https/1.1 jptyo12-3p-pac-007.ts.apple.com (acdn/255.14450), https/1.1 jptyo12-3p-pfe-013.ts.apple.com (acdn/255.14450), https/1.1 jptyo5-edge-lx-011.ts.apple.com (acdn/255.14450), https/1.1 jptyo5-edge-bx-018.ts.apple.com (acdn/255.14450)
X-Cache: hit-stale, hit-stale, miss, miss, miss

{"applinks":{"details":[{"appIDs":["Z6QR6VJL79.com.stealthtalk.client"],"components":[{"/":"/deep-link/create_enterprise_account","?":{"enterprise_id":"?*"},"comment":"App link for creating enterprise account. enteprise_id required"},{"/":"/testers/create_enterprise_account","exclude":true,"comment":"Stage appp link for creating enterprise account. Blocked for consume app."}]},{"appIDs":["Z6QR6VJL79.com.stealthtalk.client.debug"],"components":[{"/":"/testers/create_enterprise_account","?":{"enterprise_id":"?*"},"comment":"Stage app link for creating enterprise account. enteprise_id required"},{"/":"/deep-link/create_enterprise_account","exclude":true,"comment":"App link for creating enterprise account. Blocked for stage application"}]}]}}

References