Node-restify: User-Agent header stopping Gzip compression

Created on 11 Oct 2017  路  2Comments  路  Source: restify/node-restify

  • [x] Used appropriate template for the issue type
  • [x] Searched both open and closed issues for duplicates of this issue
  • [x] Title adequately and _concisely_ reflects the feature or the bug

Bug Report

Description

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.

Restify Version

6.0.1

Node.js Version

8.6.0

Expected behaviour

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

Actual behaviour

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

Repro case

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

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

All 2 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

domenic picture domenic  路  4Comments

Sigurthorb picture Sigurthorb  路  4Comments

augustovictor picture augustovictor  路  4Comments

blechatellier picture blechatellier  路  4Comments

nodesocket picture nodesocket  路  4Comments