diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-05-24 10:40:40 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-05-24 11:35:53 +0200 |
commit | e82ed55516fbbba252b6dbfede49745eeea9e269 (patch) | |
tree | 0c1d5716ca6cc137c71b7aa3cbe57b6e790265f5 | |
parent | 0bd3d0ff4c3c51aeae2ce1735c9028a1ac34cdaa (diff) | |
download | mitmproxy-e82ed55516fbbba252b6dbfede49745eeea9e269.tar.gz mitmproxy-e82ed55516fbbba252b6dbfede49745eeea9e269.tar.bz2 mitmproxy-e82ed55516fbbba252b6dbfede49745eeea9e269.zip |
close existing server_conn before replacing it
-rw-r--r-- | mitmproxy/net/tcp.py | 4 | ||||
-rw-r--r-- | mitmproxy/proxy/protocol/http_replay.py | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/mitmproxy/net/tcp.py b/mitmproxy/net/tcp.py index 73b1088f..f17943c1 100644 --- a/mitmproxy/net/tcp.py +++ b/mitmproxy/net/tcp.py @@ -569,7 +569,9 @@ class TCPClient(_Connection): # Make sure to close the real socket, not the SSL proxy. # OpenSSL is really good at screwing up, i.e. when trying to recv from a failed connection, # it tries to renegotiate... - if isinstance(self.connection, SSL.Connection): + if not self.connection: + return + elif isinstance(self.connection, SSL.Connection): close_socket(self.connection._socket) else: close_socket(self.connection) diff --git a/mitmproxy/proxy/protocol/http_replay.py b/mitmproxy/proxy/protocol/http_replay.py index 25867871..1aa91847 100644 --- a/mitmproxy/proxy/protocol/http_replay.py +++ b/mitmproxy/proxy/protocol/http_replay.py @@ -83,7 +83,11 @@ class RequestReplayThread(basethread.BaseThread): server.wfile.write(http1.assemble_request(r)) server.wfile.flush() + + if self.f.server_conn: + self.f.server_conn.close() self.f.server_conn = server + self.f.response = http.HTTPResponse.wrap( http1.read_response( server.rfile, |