views:

237

answers:

3

I'm using Amazon S3 to serve static files. When the Content-Type is just 'text/css' and I haven't compressed the file, it is returned ok. If I try to zlib.compress() the contents that will be returned and change Content-Encoding to 'gzip', the browser cannot decode the result. In Chrome, the error is

Error 330 net::ERR_CONTENT_DECODING_FAILED

in Safari,

“cannot decode raw data” (NSURLErrorDomain:-1015)

Is there something special to do with python's zlib to make sure the result can be returned and decompressed by the browser?

+1  A: 

gzip is not the same as zlib.

Mark Byers
A: 

It is decodable. The problem is that the sender is lying to the receiver -- not a good way of ensuring harmonious communication. Try calling it "zlib" instead of "gzip".

John Machin
A: 

I have this same problem.

If you send the header:

Content-Encoding: gzip

Safari/Chrome show that error.

But if you instead send:

Content-Encoding: deflate

Safari/Chrome decodes the input fine.

Jon Works