Nam Thai
Nam Thai

Reputation: 851

Node.js http get request produces different result from web browser

This is login form so unfortunately I don't have a working demo. I hope that I can explain fully what's happening.

I get this result from hurl.it: enter image description here and this is the entire header and body. enter image description here

I try to simulate the same result using Node.js request module:

var request = require ('request');

request
  .get({
    uri: "https://app.bom.com/j_login_user",
    qs: {
      "email": "email",
      "password": "pass"
    },
    headers: {
      "accept": "*/*",
      "accept-encoding": "gzip, deflate",
      "user-agent": "runscope/0.1",
      "connection": "keep-alive"
    }
  })
  .on('response', function(response) {
    log.info(response);
  });

However, the result is entirely different from the one hurl.it produce. Here is a pastebin of the response object, with response code 200 instead of 302: http://pastebin.com/rKEH0Uwr

Upvotes: 1

Views: 549

Answers (1)

mscdex
mscdex

Reputation: 106696

request by default handles redirects automatically, so you'll never see the 302 response code.

Upvotes: 1

Related Questions