[Python-checkins] python/dist/src/Lib urllib2.py,1.41,1.42
jhylton@users.sourceforge.net
jhylton@users.sourceforge.net
Sun, 04 May 2003 21:09:15 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv22598
Modified Files:
urllib2.py
Log Message:
Better fix for newurl as suggested by Jim Jewett in SF bug #730963.
Index: urllib2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** urllib2.py 5 May 2003 01:47:13 -0000 1.41
--- urllib2.py 5 May 2003 04:09:13 -0000 1.42
***************
*** 409,413 ****
class HTTPRedirectHandler(BaseHandler):
! def redirect_request(self, req, fp, code, msg, headers):
"""Return a Request or None in response to a redirect.
--- 409,413 ----
class HTTPRedirectHandler(BaseHandler):
! def redirect_request(self, req, fp, code, msg, headers, newurl):
"""Return a Request or None in response to a redirect.
***************
*** 418,431 ****
None if you can't but another Handler might.
"""
- # XXX 301 and 302 errors must have a location or uri header.
- # Not sure about the other error codes.
- if "location" in headers:
- newurl = headers["location"]
- elif "uri" in headers:
- newurl = headers["uri"]
- else:
- return
- newurl = urlparse.urljoin(req.get_full_url(), newurl)
-
m = req.get_method()
if (code in (301, 302, 303, 307) and m in ("GET", "HEAD")
--- 418,421 ----
***************
*** 456,460 ****
# request, although that might interact poorly with other
# handlers that also use handler-specific request attributes
! new = self.redirect_request(req, fp, code, msg, headers)
if new is None:
return
--- 446,450 ----
# request, although that might interact poorly with other
# handlers that also use handler-specific request attributes
! new = self.redirect_request(req, fp, code, msg, headers, newurl)
if new is None:
return