Messages, representations and files
Content-Length, compression and framing
Byte count is not character count.
Understand the concept
Content-Length counts transferred body bytes, not characters. UTF-8 characters can occupy several bytes. Content-Encoding describes transformations such as gzip/br, while Content-Type describes media format. Compressed and decoded lengths differ.
HTTP/1.1 chunking can transfer a body without knowing its final length. HTTP/2 and HTTP/3 use their own framing rather than chunked Transfer-Encoding. Intermediaries must agree on message boundaries; conflicting framing fields can create parsing and security failures. Use maintained protocol implementations.
Compression trades CPU for bandwidth and may add little value for small or already-compressed content. Compressing secrets beside attacker-controlled data can introduce side channels. Smaller payloads are not evidence of security.
Diagnose truncation, size mismatches and intermediary issues.
Using character length as Content-Length.
One topic. Three levels of depth.
Content-Type: text/plain; charset=utf-8Account for UTF-8 byte length.
This page does not send requests to external servers. Messages are readable HTTP/1.1 illustrations, not HTTP/2 or HTTP/3 wire dumps. example.test is reserved for examples. Run commands and JavaScript only in your own test environment; never publish real tokens or cookies.
Try it yourself first.
Must decoded gzip content equal Content-Length?
Show the solution and explanation
Transferred bytes ≠ decoded bytesNo; transfer size and decoded size are different measurements.