1

I'm trying to use request module to get HTTP status code. But sometimes it works wrong. For example:

var request = require('request');
var requestSettings = {
    method: 'HEAD',
    url: 'http://stackoverflow.com/help'
};
request(requestSettings, function(error, response, body) {
    console.log(response.statusCode);
});   

This code returns 404 (not 200 as expected).
Why might this happen?
Thanks.

1
  • Doesn't seem to be specific to node. When curl http://stackoverflow.com/help -I also returns 404 while curl http://stackoverflow.com/help -i shows 200. Guess SO dosen't like HEAD requests. Commented Jun 28, 2013 at 7:37

1 Answer 1

1

You're doing everything fine. stackoverflow didn't implement HEAD

telnet HEAD request

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.