~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/_urllib2_wrappers.py

Tags: bzr-1.9
(mbp) prepare 1.9final

Show diffs side-by-side

added added

removed removed

Lines of Context:
232
232
        httplib.HTTPConnection.connect(self)
233
233
 
234
234
 
235
 
# FIXME: Should test for ssl availability
 
235
# Build the appropriate socket wrapper for ssl
 
236
try:
 
237
    import ssl # python 2.6
 
238
    _ssl_wrap_socket = ssl.wrap_socket
 
239
except ImportError:
 
240
    def _ssl_wrap_socket(sock, key_file, cert_file):
 
241
        ssl_sock = socket.ssl(sock, key_file, cert_file)
 
242
        return httplib.FakeSocket(sock, ssl_sock)
 
243
 
 
244
 
236
245
class HTTPSConnection(AbstractHTTPConnection, httplib.HTTPSConnection):
237
246
 
238
247
    def __init__(self, host, port=None, key_file=None, cert_file=None,
251
260
            self.connect_to_origin()
252
261
 
253
262
    def connect_to_origin(self):
254
 
        ssl = socket.ssl(self.sock, self.key_file, self.cert_file)
255
 
        self.sock = httplib.FakeSocket(self.sock, ssl)
 
263
        self.sock = _ssl_wrap_socket(self.sock, self.key_file, self.cert_file)
256
264
 
257
265
 
258
266
class Request(urllib2.Request):