aboutsummaryrefslogtreecommitdiffstats
path: root/pathod/pathoc.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2016-06-12 11:35:20 +1200
committerGitHub <noreply@github.com>2016-06-12 11:35:20 +1200
commite0d6434b27ed16805a2b306f85fd9de0b7971574 (patch)
tree83934cad2a5918fd7b22a7236985356dfc9cced3 /pathod/pathoc.py
parent1d4403096393369e0a8038ad79434ac26b503de3 (diff)
parente58a2bf0956c6916ebba2477df0320b554c139e2 (diff)
downloadmitmproxy-e0d6434b27ed16805a2b306f85fd9de0b7971574.tar.gz
mitmproxy-e0d6434b27ed16805a2b306f85fd9de0b7971574.tar.bz2
mitmproxy-e0d6434b27ed16805a2b306f85fd9de0b7971574.zip
Merge pull request #1247 from cortesi/appveyor
Be stricter about handling connetcts in the pathoc test suite
Diffstat (limited to 'pathod/pathoc.py')
-rw-r--r--pathod/pathoc.py67
1 files changed, 34 insertions, 33 deletions
diff --git a/pathod/pathoc.py b/pathod/pathoc.py
index b2563988..21fc9845 100644
--- a/pathod/pathoc.py
+++ b/pathod/pathoc.py
@@ -291,44 +291,45 @@ class Pathoc(tcp.TCPClient):
if self.use_http2 and not self.ssl:
raise NotImplementedError("HTTP2 without SSL is not supported.")
- ret = tcp.TCPClient.connect(self)
- if connect_to:
- self.http_connect(connect_to)
+ with tcp.TCPClient.connect(self) as closer:
+ if connect_to:
+ self.http_connect(connect_to)
- self.sslinfo = None
- if self.ssl:
- try:
- alpn_protos = [b'http/1.1']
- if self.use_http2:
- alpn_protos.append(b'h2')
-
- self.convert_to_ssl(
- sni=self.sni,
- cert=self.clientcert,
- method=self.ssl_version,
- options=self.ssl_options,
- cipher_list=self.ciphers,
- alpn_protos=alpn_protos
+ self.sslinfo = None
+ if self.ssl:
+ try:
+ alpn_protos = [b'http/1.1']
+ if self.use_http2:
+ alpn_protos.append(b'h2')
+
+ self.convert_to_ssl(
+ sni=self.sni,
+ cert=self.clientcert,
+ method=self.ssl_version,
+ options=self.ssl_options,
+ cipher_list=self.ciphers,
+ alpn_protos=alpn_protos
+ )
+ except exceptions.TlsException as v:
+ raise PathocError(str(v))
+
+ self.sslinfo = SSLInfo(
+ self.connection.get_peer_cert_chain(),
+ self.get_current_cipher(),
+ self.get_alpn_proto_negotiated()
)
- except exceptions.TlsException as v:
- raise PathocError(str(v))
+ if showssl:
+ print(str(self.sslinfo), file=fp)
- self.sslinfo = SSLInfo(
- self.connection.get_peer_cert_chain(),
- self.get_current_cipher(),
- self.get_alpn_proto_negotiated()
- )
- if showssl:
- print(str(self.sslinfo), file=fp)
+ if self.use_http2:
+ self.protocol.check_alpn()
+ if not self.http2_skip_connection_preface:
+ self.protocol.perform_client_connection_preface()
- if self.use_http2:
- self.protocol.check_alpn()
- if not self.http2_skip_connection_preface:
- self.protocol.perform_client_connection_preface()
+ if self.timeout:
+ self.settimeout(self.timeout)
- if self.timeout:
- self.settimeout(self.timeout)
- return ret
+ return closer.pop()
def stop(self):
if self.ws_framereader: