On Wed, 19 Jun 2002 [EMAIL PROTECTED] wrote:
> On Wed, 19 June 2002, "John J. Lee" wrote
>
> > I think this
> > logic is in accordance with RFC 2616. See Python
[...]
> My reading of the cited RFC leads me to believe that
> the behavior of the code above will match the "MUST"s
> of the RFC, but will fail to work like most current
> browsers. From the RFC:
[...]
Yes, agreed. Actually, this was what I suggested to the Python people in
the first place (though I had the rest of it wrong). Some confusion
later, I think we've finally settled on the right answer -- which is in
agreement with how you just explained it. I just proposed the following
(excuse the diff pluses) for Python's urllib2, and presumably something
very similar should be in LWP:
+ def redirect_request(self, req, fp, code, msg, headers):
+ """Return a Request or None in response to a redirect.
+
+ This is called by the http_error_30x methods when a redirection
+ response is received. If a redirection should take place, return
a
+ new Request to allow http_error_30x to perform the redirect;
+ otherwise, return None to indicate that an HTTPError should be
+ raised.
+
+ """
+ if (code in (301, 302, 303, 307) and req.method() in ("GET",
"HEAD") or
+ code in (302, 303) and req.method() == "POST"):
+ return Request(newurl, headers=req.headers)
+ else:
+ return None
See
http://sourceforge.net/tracker/?func=detail&aid=549151&group_id=5470&atid=105470
for the discussion.
John