[Python-checkins] CVS: python/dist/src/Lib urllib2.py,1.10,1.11

Moshe Zadka moshez@users.sourceforge.net
Tue, 20 Mar 2001 05:14:31 -0800


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

Modified Files:
	urllib2.py 
Log Message:
* Fixing the password-proxy bug 
* Not sending content-type and content-length twice


Index: urllib2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** urllib2.py	2001/03/16 08:29:47	1.10
--- urllib2.py	2001/03/20 13:14:28	1.11
***************
*** 478,483 ****
          if '@' in host:
              user_pass, host = host.split('@', 1)
!             user_pass = base64.encode_string(unquote(user_passw)).strip()
!             req.addheader('Proxy-Authorization', user_pass)
          host = unquote(host)
          req.set_proxy(host, type)
--- 478,483 ----
          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)
***************
*** 782,786 ****
  
      def do_open(self, http_class, req):
!         host = req.get_host()
          if not host:
              raise URLError('no host given')
--- 782,786 ----
  
      def do_open(self, http_class, req):
!         host = urlparse.urlparse(req.get_full_url())[1]
          if not host:
              raise URLError('no host given')
***************
*** 791,797 ****
                  data = req.get_data()
                  h.putrequest('POST', req.get_selector())
!                 h.putheader('Content-type',
!                             'application/x-www-form-urlencoded')
!                 h.putheader('Content-length', '%d' % len(data))
              else:
                  h.putrequest('GET', req.get_selector())
--- 791,799 ----
                  data = req.get_data()
                  h.putrequest('POST', req.get_selector())
!                 if not req.headers.has_key('Content-type'):
!                     h.putheader('Content-type',
!                                 'application/x-www-form-urlencoded')
!                 if not req.headers.has_key('Content-length'):
!                     h.putheader('Content-length', '%d' % len(data))
              else:
                  h.putrequest('GET', req.get_selector())
***************
*** 799,803 ****
              raise URLError(err)
  
-         # XXX proxies would have different host here
          h.putheader('Host', host)
          for args in self.parent.addheaders:
--- 801,804 ----