That does seem to be the case. To summarize I run both examples (using http.get and 'request' module) and the output is as follows:
(HTTP.GET) 1st redirect Statuscode: 301 location: 'http://bit.ly/Hwhiyt' server: 'hi' 2nd redirect Statuscode: 301 location: 'http://www.scoop.it/t/nodejs-code/p/1573117519/is-node-better' server: 'nginx' (REQUEST) Using followRedirect: false Statuscode: 301 location: 'http://bit.ly/Hwhiyt' server: 'hi' Using maxRedirects: '1' [Error: Exceeded maxRedirects. Probably stuck in a redirect loop.] So, if it cannot get a response with Statuscode:200 within the specified number of redirects it throws and error. It's is getting a 301, but that is ignored. Using maxRedirects: '2' Statuscode: 200 location: undefined server: 'Jetty(7.5.4.v20111024)', Redirects on the same host are not considered in the count of maxRedirects, else it should have returned 301 as in http.get above. Note the server in each case. The one using http.get has an nginx server. So there is an internal redirect taking place. So we can use 'request' only to get the first redirect (using followRedirect: false) or the final response. Not sure if the maxRedirects parameter was intended to work this way. On Fri, May 4, 2012 at 12:32 AM, mscdex <[email protected]> wrote: > On May 3, 10:40 am, Anand George <[email protected]> wrote: > > The location parameter is missing in the sond response. It couldn't be an > > issue with the servers, cause the response from both servers have been > > verified using our http.get example. Just wondering if request formats > the > > response differently in each case? > > The reason is that when you tell it not to automatically redirect > (followRedirect: false), you'll see the Location header containing the > url where the request module would have redirected to. However, when > you tell the request module to follow at most 2 redirects for this > particular url, there is no Location header in response.headers > because there are no more redirects (perhaps there was just the one > redirect from the first example). > > So what you are seeing is expected behavior. > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
