
I've just discovered a bug in urllib2: it drops caller-supplied headers when processing HTTP redirects. See http://sourceforge.net/tracker/index.php?func=detail&aid=511786&grou... for details.
The fix (to HTTPRedirectHandler.http_error_302()), as near as I can tell, is trivial:
--- Lib/urllib2.py 2001/11/09 16:46:51 1.24 +++ Lib/urllib2.py 2002/02/01 17:00:05 @@ -416,7 +416,7 @@ # XXX Probably want to forget about the state of the current # request, although that might interact poorly with other # handlers that also use handler-specific request attributes - new = Request(newurl, req.get_data()) + new = Request(newurl, req.get_data(), req.headers) new.error_302_dict = {} if hasattr(req, 'error_302_dict'): if len(req.error_302_dict)>10 or \
I'll check this in (2.2.1 candidate) and close the bug unless anyone howls.
Greg
participants (1)
-
Greg Ward