When connecting to a restify server (with plugin gzipResponse) from a web browser it isn't returning a Content-Encoding header and the response isn't compressed.
I have narrowed it down to the User-Agent header being to cause.
6.0.1
8.6.0
curl -i --header "User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" --compress localhost:5000
Returns:
Server: restify
Content-Encoding: gzip
Content-Type: text/plain
Date: Wed, 11 Oct 2017 08:31:53 GMT
Connection: keep-alive
Transfer-Encoding: chunked
Hello World
curl -i --header "User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" --compress localhost:5000
Returns:
Server: restify
Content-Type: text/plain
Date: Wed, 11 Oct 2017 08:31:37 GMT
Connection: keep-alive
Transfer-Encoding: chunked
Hello World
Run up the following code:
var restify = require("restify");
var server = restify.createServer();
server.use(restify.plugins.gzipResponse());
server.listen(5000, function() {
console.info(`Server listening on port: 5000`);
});
server.get("/", function(req, res, next) {
res.setHeader("Content-Type", "text/plain");
res.send("Hello World");
return next();
});
Test using curl
curl -i --header "User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" --compress localhost:5000
The user-agent value is the one sent from Google Chrome
Hi @maxaction, using your repro I seem to be getting the content-encoding header:
$ curl -i --header "User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" --compress localhost:5000
HTTP/1.1 200 OK
Server: restify
Content-Encoding: gzip
Content-Type: text/plain
Date: Sun, 15 Oct 2017 06:09:47 GMT
Connection: keep-alive
Transfer-Encoding: chunked
Am I looking at the right thing?
You are looking at the correct thing.
I have just looked at it a bit more and tried it on another computer and it is working fine on that.
The only difference between the two machine is one has and anti-virus installed and one does not.
The antivirus is stripping the header.
If anyone else has this issue my antivirus is ESET Endpoint Security and you will need to disable "application protocol content filtering" to get gzip encoding it to work
Closing due to it being an antivirus issue
Most helpful comment
You are looking at the correct thing.
I have just looked at it a bit more and tried it on another computer and it is working fine on that.
The only difference between the two machine is one has and anti-virus installed and one does not.
The antivirus is stripping the header.
If anyone else has this issue my antivirus is ESET Endpoint Security and you will need to disable "application protocol content filtering" to get gzip encoding it to work
Closing due to it being an antivirus issue