maxRedirect: 1 gives the same result. Error code shows
[Error: Exceeded maxRedirects. Probably stuck in a redirect loop.].

Based on this tried using followRedirect : false in the options. This
worked returning the first url. Thanks.

Next tried with maxRedirects:2 followRedirect: true(default).

Now the only problem seems to be that response.headers.location is
undefined in the second URL. Here's a snapshot of the two responses

1st response with followRedirect: false

{ date: 'Thu, 03 May 2012 14:29:53 GMT',
  server: 'hi',
*  location: 'http://bit.ly/Hwhiyt',*
  'cache-control': 'private,max-age=300',
  expires: 'Thu, 03 May 2012 14:34:53 GMT',
  'content-length': '0',
  connection: 'close',
  'content-type': 'text/html; charset=UTF-8' }

2nd response with maxRedirect: 2

{ date: 'Thu, 03 May 2012 14:32:46 GMT',
  server: 'Jetty(7.5.4.v20111024)',
  'content-type': 'text/html;charset=UTF-8',
  'content-language': 'en',
  pragma: 'no-cache',
  'cache-control': 'no-cache',
  expires: 'Thu, 01 Jan 1970 00:00:00 GMT',
  'content-length': '300849',
  'set-cookie':
   [ 'userId=8273323c-c80c-4884-a9c1-c3013bc603d1;Path=/;Expires=Sun,
01-May-2022 14:32:47 GMT',
     'visited-topics=438305;Path=/;Expires=Sun, 10-Jan-2044 16:19:27 GMT' ],
  via: '1.1 www.scoop.it',
  vary: 'Accept-Encoding',
  'keep-alive': 'timeout=15, max=100',
  connection: 'Keep-Alive' }

The location parameter is missing in the second 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?


On Thu, May 3, 2012 at 6:37 PM, mscdex <msc...@gmail.com> wrote:

> On May 3, 6:29 am, Anand George <mranandgeo...@gmail.com> wrote:
> > , maxRedirects: '1'
>
> What if you set this to the number 1 instead of a string of '1' (e.g.
> maxRedirects: 1)?
>
> > , function (error, response, body) {
> >     console.log(response.headers);
> >
> > })
> >
> > I get an error Cannot read property 'headers' of undefined
>
> What does the error variable say when response is undefined?
>
> --
> 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 nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to