Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Weird followAllRedirects behavior on POST #289

Closed
topfunky opened this Issue · 17 comments

9 participants

@topfunky

With Node 0.8.2 and request 2.9.203, I'm getting a weird timeout with POST (or PUT) and the followAllRedirects option.

It either hangs indefinitely or eventually registers a timeout.

I can recreate the same functionality by making another GET request in the callback, but the built-in functionality should handle it without that.

I'm using request extensively in my tests and it would be great to have this working again. It worked perfectly in Node 0.6.

The closest thing I can figure out is that it's hanging once it kicks off the call to stream internally in the request module.

Here's a sample of the way I'm using request:

request.post('http://localhost/sessions', {
  form: {
    email: 'user@example.com',
    password: '12345'
  },
  followAllRedirects: true
}, function(err, res, body) {
  console.log(body)
})
@mikeal
Owner

@isaacs what changed in 0.8 that might make this happen?

@isaacs

Nothing changed in 0.8 that would cause this, that I know of. @topfunky what 0.6 have you tested with? Some things did shift around in teh 0.6.12 - 0.6.18 area.

@isaacs isaacs referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@isaacs isaacs referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@isaacs

Added a test on 936b43e157178aa1687fec586fcc430d6d3ebd64 that seems to pass.

@topfunky Share more of your code. My guess is that the server is hanging, not request.

@parshap

I'm seeing this too since upgrading from 2.9.153 to 2.9.203, both on 0.6. The server responds with a 303 to the initial POST, but never receives the subsequent GET. I'll try to post more info, but have been having trouble recreating an isolated example.

@isaacs

Can you please share some code?

My test does not use a 303 status code. I'll try that.

@isaacs isaacs referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@isaacs isaacs referenced this issue from a commit in isaacs/request
@isaacs isaacs Test for #289
Seems to work as expected
d38e57b
@isaacs isaacs referenced this issue from a commit in isaacs/request
@isaacs isaacs A test of POST redirect following with 303 status
Re: #289
820af58
@isaacs

Added another test on 820af58.

Still passes.

It can be useful to just track the requests and responses with wireshark or pcap or something. That'd provide a lot of information.

@dmkc

I'm having the same issue. followRedirect is disabled for POST requests, and followAllRedirects just leaves the request hanging.

@isaacs

@imissmyjuno Show the code or I do not believe you.

@dmkc

I can't seem to replicate this on another server… It's an internal URL that I can't share, and the same scenario on another unrelated public server (POST request that returns a 302) does work correctly.

@parshap

Yes, this is my exact same situation, @imissmyjuno. The tests I created pass, but my code fails. I tracked it down to the second http.request being made, but the callback never being called. I will hopefully have some time over the next week or two to take a closer look at this and figure out exactly what is going on. Unfortunately the reality is that it's easy to workaround not having followAllRedirects, so I haven't been able to put as much time into debugging this as I'd like.

@mhart

I'm seeing the same thing when trying to integrate with OpenX's API - where one of the steps requires a POST that returns a 302 - request just hangs at this point.

Will try to reproduce on a local app.

@mhart

Can't reproduce locally. Here's a simple test case that will reproduce it though (perhaps HTTPS is the issue?)

request.post('https://sso.openx.com/login/process', {
  followAllRedirects: true,
  form: {
    email: 'michael.hart+githubtest@apps.webfirmgroup.com',
    password: 'GitHubT3st'
  }
}, function(err, res, body) {
  console.log(err ? err : body);
});
@abasiri

This seems to reproduce it, if you take out followAllRedirects it runs, but with it, it will hang. Same issue with HTTP & HTTPS
Run file2.js

file1.js

request.post('https://sso.openx.com/login/process', {
  followAllRedirects: true,
  form: {
    email: 'michael.hart+githubtest@apps.webfirmgroup.com',
    password: 'GitHubT3st'
  }
}, function(err, res, body) {
  console.log(err ? err : body);
});

file2.js

fs = require("fs")

fs.readFile('file1.js', "ascii", function (err, data) {
  eval(data);
});
@ThiefMaster

bump - any news on this? That bug is pretty annoying and makes this library unusable e.g. when openid logins are involved (which often require redirects after a POST request being followed)

@dmatesic

Any updates on this?

@mikeal
Owner

Is this still an issue?

This is so old I'm closing, if it is actually still an issue just let me know and I'll re-open.

@mikeal mikeal closed this
@mhart

Not sure. The account I was using has long expired. We ended up having to manually redirect when we got a 302 in this particular case as request wasn't following it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.