Question

I am writing a small web server and would like to send gzipped data.

In the http header for the Content-Length field do I set the length of the compressed data or the length of the uncompressed data?

Was it helpful?

Solution

Compressed.

OTHER TIPS

You have to specify the size of the actual data being sent, which in your case would be the compressed data size.

However, something to keep in mind - if the data is being sent as chunked ("Transfer-Encoding: chunked"), then you are NOT allowed to send a Content-Length header at all. The chunking dictates how the bytes are read. A Content-Length header would break the client's abilty to read the chunks correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top