summaryrefslogtreecommitdiffstats
path: root/Lib/urllib.py
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2000-04-23 02:53:11 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2000-04-23 02:53:11 (GMT)
commit141e9894b7818daa06773d50705d7c64d298f9d8 (patch)
treece56860a75be8b9f6b3178490a0e789d4cb9bd57 /Lib/urllib.py
parent66bf4462730b95dd23cfecb7ac8ecfa01a467d46 (diff)
downloadcpython-141e9894b7818daa06773d50705d7c64d298f9d8.zip
cpython-141e9894b7818daa06773d50705d7c64d298f9d8.tar.gz
cpython-141e9894b7818daa06773d50705d7c64d298f9d8.tar.bz2
Fixed bug reported by JP Calderone: https:// URL's didn't work.
The fix also adds support for POSTing to an https URL
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r--Lib/urllib.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 7bc9f17..a1dcbda 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -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()