views:

107

answers:

2

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?

+3  A: 

Compressed.

Stephen Doyle
A: 

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.

Remy Lebeau - TeamB