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

HEAD requests with Node v5 have issues with gzipped content and fail. #2045

Closed
czardoz opened this issue Jan 29, 2016 · 5 comments
Closed

HEAD requests with Node v5 have issues with gzipped content and fail. #2045

czardoz opened this issue Jan 29, 2016 · 5 comments

Comments

@czardoz
Copy link
Contributor

czardoz commented Jan 29, 2016

This script reproduces the issue:

    var req = require('request');

    req({
        url: 'http://google.com',
        method: 'HEAD',
        headers: {},
        followAllRedirects: false,
        followRedirect: true,
        jar: true,
        timeout: 15000,
        gzip: true,
        rejectUnauthorized: false,
        strictSSL: true
    }, function (err, res, body) {
        if (err) {
            console.error(err.stack || err);
        }
    });

Steps to reproduce:

aniket [/tmp/request-bug] -> node -v
v5.1.0
aniket [/tmp/request-bug] -> npm -v
3.3.12
aniket [/tmp/request-bug] -> cat node_modules/request/package.json| grep version
  "version": "2.69.0"
aniket [/tmp/request-bug] -> node reproduce.js 
Error: unexpected end of file
    at Zlib._handle.onerror (zlib.js:363:17)
aniket [/tmp/request-bug] -> 
@czardoz czardoz changed the title HEAD requests with Node v5 have issues with gzipped content fail. HEAD requests with Node v5 have issues with gzipped content and fail. Feb 5, 2016
@nathanmarks
Copy link

@czardoz FWIW I had the same issue with some HEAD requests and it is because of followAllRedirects. Unless you set it to true, it won't follow HEAD redirects (IE non www to www, or http to https).

edit: Nvm, I see the issue with more URLs now too.

@czardoz
Copy link
Contributor Author

czardoz commented Mar 4, 2016

Is this issue reproducible for others?

@simov Is there a label for a "confirmed" bug? I can consistently reproduce it with Node v5.

@nathanmarks
Copy link

@czardoz Not sure if this helps you, but I was doing HEAD requests to avoid downloading entire responses.

I ended up switching to GET requests, streaming the response and aborting the request early.

@czardoz
Copy link
Contributor Author

czardoz commented Mar 8, 2016

@nathanmarks While that's a viable workaround, I use this library to run user-specified HTTP requests, so I cannot really change the request method :)

@simov
Copy link
Member

simov commented Apr 16, 2016

Fixed here #2176

Let me know what do you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants