Skip to content

Commit 93ee4a0

Browse files
committed
HTTPS requests over HTTP proxy now work on either Python 2.4, 2.5 and 2.6+
1 parent 81d1a76 commit 93ee4a0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/request/proxy.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
import urllib
3030
import urllib2
3131

32+
from lib.core.settings import PYVERSION
33+
34+
35+
if PYVERSION >= "2.6":
36+
import ssl
37+
3238

3339
class ProxyHTTPConnection(httplib.HTTPConnection):
3440
_ports = {"http" : 80, "https" : 443}
@@ -98,8 +104,12 @@ def connect(self):
98104
ProxyHTTPConnection.connect(self)
99105

100106
# Make the sock ssl-aware
101-
ssl = socket.ssl(self.sock, self.key_file, self.cert_file)
102-
self.sock = httplib.FakeSocket(self.sock, ssl)
107+
if PYVERSION >= "2.6":
108+
sslobj = ssl.wrap_socket(self.sock, self.key_file, self.cert_file)
109+
self.sock = sslobj
110+
else:
111+
sslobj = socket.ssl(self.sock, self.key_file, self.cert_file)
112+
self.sock = httplib.FakeSocket(self.sock, sslobj)
103113

104114

105115
class ProxyHTTPHandler(urllib2.HTTPHandler):

0 commit comments

Comments
 (0)