Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User-Agent header stopping Gzip compression #1515

Closed
maxaction opened this Issue Oct 11, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@maxaction
Copy link

maxaction commented Oct 11, 2017

  • Used appropriate template for the issue type
  • Searched both open and closed issues for duplicates of this issue
  • 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

@DonutEspresso

This comment has been minimized.

Copy link
Member

DonutEspresso commented Oct 15, 2017

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?

@maxaction

This comment has been minimized.

Copy link
Author

maxaction commented Oct 15, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.