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

Problem with redirect handling #26

Closed
twleung opened this issue Apr 24, 2011 · 5 comments
Closed

Problem with redirect handling #26

twleung opened this issue Apr 24, 2011 · 5 comments

Comments

@twleung
Copy link

twleung commented Apr 24, 2011

var request = require('request');
request({uri:'http://plixi.com/p/95010942'}, function (error, response, body) {
console.log(error);
console.log(response.statusCode);
if (!error && response.statusCode == 200) {
sys.puts(body) // Print the google web page.
}
})

plixi works via 302 redirect:
curl -v 'http://plixi.com/p/95243438' darwin-2.6

  • About to connect() to plixi.com port 80 (#0)
  • Trying 184.106.40.17... connected
  • Connected to plixi.com (184.106.40.17) port 80 (#0)

    GET /p/95243438 HTTP/1.1
    User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
    Host: plixi.com
    Accept: /

    < HTTP/1.1 302 Found
    < Date: Sun, 24 Apr 2011 22:01:15 GMT
    < Server: Apache/2.2.3 (Red Hat)
    < X-Powered-By: PHP/5.2.14
    < Location: http://m.plixi.com/p/95243438
    < Vary: Accept-Encoding
    < Content-Length: 0
    < Content-Type: text/html; charset=UTF-8
    <
  • Connection #0 to host plixi.com left intact
  • Closing connection #0

Somewhere something is going wrong with redirect handling...

@EvanCarroll
Copy link

Can you verify that you're not POSTing or PUTing to the destination responding with the 302?

@twleung
Copy link
Author

twleung commented May 5, 2011

I am not POSTING or PUTing.

@EvanCarroll
Copy link

Well, firstly this seems like a 301 Redirrect to me

$ curl -i http://plixi.com/p/95010942
HTTP/1.1 301 Moved Permanently
Server: nginx/0.8.8
Date: Thu, 05 May 2011 22:03:20 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: keep-alive
Location: http://lockerz.com/s/95010942
Content-Length: 311

And, it seems like it isn't redirecting to the Google Homepage, but to lockerz.com.

var request = require('request');
request({uri:'http://plixi.com/p/95010942'}, function (error, response, body) {
  console.log(error);
  console.log(response.statusCode);
  if (!error && response.statusCode == 200) {
    console.log(body.match(/<title>(.*)<\/title>/)[0])
  }
})

It seems to work

null
200
<title>Lockerz.com .:. Benjamin Black's Photos - ...</title>

Try to update your copy of Request.. npm install request.

@kai5263499
Copy link

I get an exception when I try to visit http://google.com, here's my output:

Querying url with opts: {"uri":"http://google.com","followRedirect":true,"headers":{"User-Agent":"Mozilla/5.0 (Windows NT 6.0) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.60 Safari/534.24"}}

node.js:183
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: This request has been piped before http.request() was called.
    at [object Object].end (/usr/src/request/main.js:315:24)
    at Array.<anonymous> (/usr/src/request/main.js:298:15)
    at EventEmitter._tickCallback (node.js:175:26)

Seems redirect-related but the strange thing is that some redirects succeed while others fail.

@mikeal
Copy link
Member

mikeal commented Jul 21, 2011

I'm 99% sure this is fixed now.

@mikeal mikeal closed this as completed Jul 21, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants