HTTP Content-Encoding: gzip not recognized and wrong Content-Length
I'm developing a nodeJS Proxy and stumbled over a strange behaviour of
Google Chrome, which I also can reproduce in Fiddler.
If I send gzipped content to the browser, it doesn't recognize the
different zipped/unzipped content sizes. But the content is still beeing
displayed correctly.
Here a small piece of code to reproduce the problem:
var http = require('http'),
zlib = require('zlib'),
fs = require('fs');
var Proxy = http.createServer(function(request, response) {
var raw = fs.createReadStream('test');
response.writeHead(200, {
'content-encoding': 'gzip',
});
raw.pipe(zlib.createGzip()).pipe(response);
});
Proxy.listen(8000);
The file 'test' contains some dummy HTML, filesize is about 90KB. It test
the code like this:
$ curl localhost:8000 | gunzip
This works correctly so I think the nodeJS code is correct.
The Problem
This is a screeonshot of the gzipped response. The Size and Content values
are nearly the same. But I expect to be the received gzipped content
(Size) to be much smaller then the unzipped content (Content).
Also, I do not see the expected "Content-Encoding: gzip" header. And the
"Content-Length" header shows the length of the uncompressed file. I get
the same results if I pipe the HTTP traffic through Fiddler
This URL produces the expceted behaviour:
http://www.heise.de/js/jquery/jquery-1.7.1.min.js
So, what am i doing wrong?
Why is Chrome showing the wrong sizes? Or does the nodeJS code send
something wrong as response?
No comments:
Post a Comment