11from superlance .compat import httplib
22import socket
3+ import ssl
4+
35
46class TimeoutHTTPConnection (httplib .HTTPConnection ):
57 """A customised HTTPConnection allowing a per-connection
@@ -12,7 +14,7 @@ def connect(self):
1214
1315 e = "getaddrinfo returns an empty list"
1416 for res in socket .getaddrinfo (self .host , self .port ,
15- 0 , socket .SOCK_STREAM ):
17+ 0 , socket .SOCK_STREAM ):
1618 af , socktype , proto , canonname , sa = res
1719 try :
1820 self .sock = socket .socket (af , socktype , proto )
@@ -28,6 +30,7 @@ def connect(self):
2830 if not self .sock :
2931 raise socket .error (e )
3032
33+
3134class TimeoutHTTPSConnection (httplib .HTTPSConnection ):
3235 timeout = None
3336
@@ -36,7 +39,6 @@ def connect(self):
3639
3740 sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
3841 if self .timeout :
39- self . sock .settimeout (self .timeout )
42+ sock .settimeout (self .timeout )
4043 sock .connect ((self .host , self .port ))
41- ssl = socket .ssl (sock , self .key_file , self .cert_file )
42- self .sock = httplib .FakeSocket (sock , ssl )
44+ self .sock = ssl .wrap_socket (sock , self .key_file , self .cert_file )
0 commit comments