]> granicus.if.org Git - python/commitdiff
Fixed bug reported by JP Calderone: https:// URL's didn't work.
authorAndrew M. Kuchling <amk@amk.ca>
Sun, 23 Apr 2000 02:53:11 +0000 (02:53 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Sun, 23 Apr 2000 02:53:11 +0000 (02:53 +0000)
The fix also adds support for POSTing to an https URL

Lib/urllib.py

index 7bc9f1789fb008c0191d33a0e2df05cb22c87192..a1dcbdaedb858caf7767eba0ab9fe86a660dd457 100644 (file)
@@ -299,7 +299,7 @@ class URLopener:
         raise IOError, ('http error', errcode, errmsg, headers)
 
     if hasattr(socket, "ssl"):
-        def open_https(self, url):
+        def open_https(self, url, data=None):
             """Use HTTPS protocol."""
             import httplib
             if type(url) is type(""):
@@ -323,7 +323,13 @@ class URLopener:
             h = httplib.HTTPS(host, 0,
                               key_file=self.key_file,
                               cert_file=self.cert_file)
-            h.putrequest('GET', selector)
+            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)
             h.endheaders()