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?

Jesse Vogt
  • 16,229
  • 16
  • 59
  • 72

2 Answers2

3

Compressed.

Stephen Doyle
  • 3,734
  • 1
  • 23
  • 18
1

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
  • 555,201
  • 31
  • 458
  • 770