[Python-checkins] python/dist/src/Lib urllib2.py,1.31,1.32

jhylton@users.sourceforge.net jhylton@users.sourceforge.net
Sun, 07 Jul 2002 09:57:37 -0700


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

Modified Files:
	urllib2.py 
Log Message:
Fix from SF patch #527518: proxy config with user+pass authentication.

Bug fix candidate.


Index: urllib2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** urllib2.py	3 Jun 2002 16:53:00 -0000	1.31
--- urllib2.py	7 Jul 2002 16:57:35 -0000	1.32
***************
*** 459,464 ****
          if '@' in host:
              user_pass, host = host.split('@', 1)
!             user_pass = base64.encodestring(unquote(user_pass)).strip()
!             req.add_header('Proxy-Authorization', 'Basic '+user_pass)
          host = unquote(host)
          req.set_proxy(host, type)
--- 459,467 ----
          if '@' in host:
              user_pass, host = host.split('@', 1)
!             if ':' in user_pass:
!                 user, password = user_pass.split(':', 1)
!                 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)
***************
*** 765,769 ****
              raise URLError(err)
  
!         h.putheader('Host', host)
          for args in self.parent.addheaders:
              h.putheader(*args)
--- 768,774 ----
              raise URLError(err)
  
!         scheme, sel = splittype(req.get_selector())
!         sel_host, sel_path = splithost(sel)
!         h.putheader('Host', sel_host or host)
          for args in self.parent.addheaders:
              h.putheader(*args)