[Patches] [ python-Patches-599836 ] Bugfix for urllib2.py

noreply@sourceforge.net noreply@sourceforge.net
Tue, 10 Sep 2002 11:17:57 -0700


Patches item #599836, was opened at 2002-08-25 00:25
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=599836&group_id=5470

Category: Library (Lib)
Group: Python 2.2.x
Status: Open
Resolution: None
Priority: 5
Submitted By: Jeremy Fincher (jemfinch)
Assigned to: Jeremy Hylton (jhylton)
Summary: Bugfix for urllib2.py

Initial Comment:
OpenerDirector has a default User-agent header.  That 
wouldn't be a problem, except that 
AbstractHTTPHandler uses the headers in 
OpenerDirector.addheaders *after* a Request has been 
instantiated, thus making that default override whatever 
headers were given to Request.  This patch checks to 
make sure a header isn't already in a Request before 
adding the OpenerDirector's headers.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2002-09-10 11:17

Message:
Logged In: NO 

Is there any reasons to not use the same case as Mozilla, IE
and the RFC in the User-Agent HTTP header?

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2002-09-06 08:50

Message:
Logged In: NO 

Unless you want problems, I suggest you to use the same case
as Mozilla, IE and the RFC in the User-Agent HTTP header.

--- python/dist/src/Lib/urllib.py
+++ python/dist/src/Lib/urllib.py
@@ -104,7 +104,7 @@
         self.proxies = proxies
         self.key_file = x509.get('key_file')
         self.cert_file = x509.get('cert_file')
-        self.addheaders = [('User-agent', self.version)]
+        self.addheaders = [('User-Agent', self.version)]
         self.__tempfiles = []
         self.__unlink = os.unlink # See cleanup()
         self.tempcache = None
--- python/dist/src/Lib/urllib2.py
+++ python/dist/src/Lib/urllib2.py
@@ -247,7 +247,7 @@
 class OpenerDirector:
     def __init__(self):
         server_version = "Python-urllib/%s" % __version__
-        self.addheaders = [('User-agent', server_version)]
+        self.addheaders = [('User-Agent', server_version)]
         # manage the individual handlers
         self.handlers = []
         self.handle_open = {}


----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-09-03 11:56

Message:
Logged In: YES 
user_id=6380

For Jeremy.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=599836&group_id=5470