[Python-bugs-list] [ python-Bugs-549151 ] urllib2 POSTs on redirect
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 28 Apr 2002 17:53:34 -0700
Bugs item #549151, was opened at 2002-04-26 12:04
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=549151&group_id=5470
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: John J Lee (jjlee)
>Assigned to: Jeremy Hylton (jhylton)
Summary: urllib2 POSTs on redirect
Initial Comment:
urllib2 (I'm using 1.13.22 with Python 2.0, but I assume the 2.2 branch does the same) uses the
POST method on redirect, contrary to RFC1945 section 9.3:
> 9.3 Redirection 3xx
>
> This class of status code indicates that further action needs to be
> taken by the user agent in order to fulfill the request. The action
> required may be carried out by the user agent without interaction
> with the user if and only if the method used in the subsequent
> request is GET or HEAD. A user agent should never automatically
> redirect a request more than 5 times, since such redirections usually
> indicate an infinite loop.
Can be fixed in HTTPRedirectHandler.http_error_302 by replacing
new = Request(newurl, req.get_data())
with
new = Request(newurl)
so that GET is done on redirect instead of POST.
I suppose the limit of 10 in the same function should be changed to 5, also.
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-28 20:53
Message:
Logged In: YES
user_id=6380
Hm, the way I interpret the text you quote, if the original
request is a POST, it should probably not substitute a GET
but report the error.
Assigning to Jeremy since it's his module.
----------------------------------------------------------------------
Comment By: John J Lee (jjlee)
Date: 2002-04-28 12:21
Message:
Logged In: YES
user_id=261020
1. Bug is also in 2.2 branch
2. The fix (in 2.1 and 2.2) should reflect the earlier bug fix in the 2.2 branch to add the old headers:
new = Request(newurl, headers=req.headers)
3. I guess 10 should be replaced with 4, not 5.
John
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=549151&group_id=5470