[Python-checkins] python/dist/src/Lib urllib2.py,1.50,1.51

bcannon@users.sourceforge.net bcannon@users.sourceforge.net
Tue, 17 Jun 2003 14:52:36 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv27694/Lib

Modified Files:
	urllib2.py 
Log Message:
Change all header strings to be as if they were capitalize()'ed.  Also call
capitalize in AbstractHTTPHandler before inserting headers into HTTP instance.

Closes bug #649742, again.


Index: urllib2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** urllib2.py	15 Jun 2003 23:26:29 -0000	1.50
--- urllib2.py	17 Jun 2003 21:52:34 -0000	1.51
***************
*** 255,259 ****
      def __init__(self):
          server_version = "Python-urllib/%s" % __version__
!         self.addheaders = [('User-Agent', server_version)]
          # manage the individual handlers
          self.handlers = []
--- 255,259 ----
      def __init__(self):
          server_version = "Python-urllib/%s" % __version__
!         self.addheaders = [('User-agent', server_version)]
          # manage the individual handlers
          self.handlers = []
***************
*** 508,512 ****
                  user_pass = base64.encodestring('%s:%s' % (unquote(user),
                                                             unquote(password)))
!                 req.add_header('Proxy-Authorization', 'Basic ' + user_pass)
          host = unquote(host)
          req.set_proxy(host, type)
--- 508,512 ----
                  user_pass = base64.encodestring('%s:%s' % (unquote(user),
                                                             unquote(password)))
!                 req.add_header('Proxy-authorization', 'Basic ' + user_pass)
          host = unquote(host)
          req.set_proxy(host, type)
***************
*** 667,671 ****
  class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
  
!     auth_header = 'Proxy-Authorization'
  
      def http_error_407(self, req, fp, code, msg, headers):
--- 667,671 ----
  class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
  
!     auth_header = 'Proxy-authorization'
  
      def http_error_407(self, req, fp, code, msg, headers):
***************
*** 819,826 ****
          sel_host, sel_path = splithost(sel)
          h.putheader('Host', sel_host or host)
!         for args in self.parent.addheaders:
!             name, value = args
              if name not in req.headers:
!                 h.putheader(*args)
          for k, v in req.headers.items():
              h.putheader(k, v)
--- 819,826 ----
          sel_host, sel_path = splithost(sel)
          h.putheader('Host', sel_host or host)
!         for name, value in self.parent.addheaders:
!             name = name.capitalize()
              if name not in req.headers:
!                 h.putheader(name, value)
          for k, v in req.headers.items():
              h.putheader(k, v)
***************
*** 944,948 ****
          mtype = mimetypes.guess_type(file)[0]
          headers = mimetools.Message(StringIO(
!             'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
              (mtype or 'text/plain', size, modified)))
          if host:
--- 944,948 ----
          mtype = mimetypes.guess_type(file)[0]
          headers = mimetools.Message(StringIO(
!             'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
              (mtype or 'text/plain', size, modified)))
          if host:
***************
*** 986,992 ****
              mtype = mimetypes.guess_type(req.get_full_url())[0]
              if mtype:
!                 headers += "Content-Type: %s\n" % mtype
              if retrlen is not None and retrlen >= 0:
!                 headers += "Content-Length: %d\n" % retrlen
              sf = StringIO(headers)
              headers = mimetools.Message(sf)
--- 986,992 ----
              mtype = mimetypes.guess_type(req.get_full_url())[0]
              if mtype:
!                 headers += "Content-type: %s\n" % mtype
              if retrlen is not None and retrlen >= 0:
!                 headers += "Content-length: %d\n" % retrlen
              sf = StringIO(headers)
              headers = mimetools.Message(sf)