handling redirects with cookies

Maurice Aubrey (maurice@hevanet.com)
Thu, 16 Jul 1998 16:24:12 -0600


I'm experiencing a problem when trying to fetch a page
from a site which employs cookies.

The site is returning a 302 response, with a redirect
to the same exact URL.  It also includes a cookie.  
LWP::UserAgent notices that it's the same URL, and refuses to 
follow it (including the "Client-Warning: Redirect loop detected"
message instead).  

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).

We'd also need to make sure that the cookie-set headers are
included in the final response object.

Would this be a useful change, or is it complicating things too much?
Perhaps I should just code my app to look for redirects and handle
the cookie stuff myself?

I'm using libwww-perl-5.35.

Thanks,

-- 
Maurice Aubrey <maurice@hevanet.com>

I don't like it, and I'm sorry I ever had anything to do with it.
  - Erwin Schrodinger talking about quantum mechanics.