SSL w/ urllib

Andrew Kuchling akuchlin at mems-exchange.org
Sat Apr 22 22:55:06 EDT 2000


Jp Calderone <exarkun at flashmail.com> writes:
>  f = urllib.urlopen('https://www.mudprovider.com/cgi-bin/printvars.cgi',
> params)
> TypeError: too many arguments; expected 2, got 3

You've found a bug.  I've checked a fix into the CVS tree, so you can
either update, or just apply the patch below.  Thanks for the bug
report!

--amk

Index: urllib.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/urllib.py,v
retrieving revision 1.91
diff -C2 -r1.91 urllib.py
*** urllib.py	2000/02/04 15:28:41	1.91
--- urllib.py	2000/04/23 02:48:11
***************
*** 300,304 ****
  
      if hasattr(socket, "ssl"):
!         def open_https(self, url):
              """Use HTTPS protocol."""
              import httplib
--- 300,304 ----
  
      if hasattr(socket, "ssl"):
!         def open_https(self, url, data=None):
              """Use HTTPS protocol."""
              import httplib
***************
*** 324,328 ****
                                key_file=self.key_file,
                                cert_file=self.cert_file)
!             h.putrequest('GET', selector)
              if auth: h.putheader('Authorization: Basic %s' % auth)
              for args in self.addheaders: apply(h.putheader, args)
--- 324,334 ----
                                key_file=self.key_file,
                                cert_file=self.cert_file)
!             if data is not None:
!                 h.putrequest('POST', selector)
!                 h.putheader('Content-type',
!                             'application/x-www-form-urlencoded')
!                 h.putheader('Content-length', '%d' % len(data))
!             else:
!                 h.putrequest('GET', selector)
              if auth: h.putheader('Authorization: Basic %s' % auth)
              for args in self.addheaders: apply(h.putheader, args)






More information about the Python-list mailing list