@@ -389,13 +389,11 @@ class SpeedtestHTTPConnection(HTTPConnection):
389389 """
390390 def __init__ (self , * args , ** kwargs ):
391391 source_address = kwargs .pop ('source_address' , None )
392- context = kwargs .pop ('context' , None )
393392 timeout = kwargs .pop ('timeout' , 10 )
394393
395394 HTTPConnection .__init__ (self , * args , ** kwargs )
396395
397396 self .source_address = source_address
398- self ._context = context
399397 self .timeout = timeout
400398
401399 def connect (self ):
@@ -420,6 +418,17 @@ class SpeedtestHTTPSConnection(HTTPSConnection,
420418 """Custom HTTPSConnection to support source_address across
421419 Python 2.4 - Python 3
422420 """
421+ def __init__ (self , * args , ** kwargs ):
422+ source_address = kwargs .pop ('source_address' , None )
423+ context = kwargs .pop ('context' , None )
424+ timeout = kwargs .pop ('timeout' , 10 )
425+
426+ HTTPSConnection .__init__ (self , * args , ** kwargs )
427+
428+ self .source_address = source_address
429+ self ._context = context
430+ self .timeout = timeout
431+
423432 def connect (self ):
424433 "Connect to a host on a given (SSL) port."
425434
@@ -428,8 +437,7 @@ def connect(self):
428437 kwargs = {}
429438 if hasattr (ssl , 'SSLContext' ):
430439 kwargs ['server_hostname' ] = self .host
431-
432- self .sock = self ._context .wrap_socket (self .sock , ** kwargs )
440+ self .sock = self ._context .wrap_socket (self .sock , ** kwargs )
433441
434442
435443def _build_connection (connection , source_address , timeout , context = None ):
0 commit comments