handling redirects with cookies

Charles C. Fu (ccwf@bacchus.com)
Thu, 16 Jul 1998 18:58:13 -0700 (PDT)


Maurice Aubrey writes:
> The site is returning 302, because it wants you to fetch the same
> page, but wants you to include the cookie the second time around
> (which is what terminates the redirects).  LWP doesn't seem to do
> that.

> Can we improve this?  I'm wondering if, once the redirect is noticed
> and the request is cloned, the response object could be scanned for
> cookie headers, and if present, add a cookie jar to the new request?
> It would also note that cookies were set, and would agree to follow
> the redirect even if it is identical (and fail only if max redirects
> is reached).

Max redirects should be reduced to 5, and we should fail only when
reaching that limit.  RFC 2068 (HTTP/1.1) says

   A user agent SHOULD NOT automatically redirect a request more than
   5 times, since such redirections usually indicate an infinite loop.

-ccwf