aboutsummaryrefslogtreecommitdiffstats
path: root/netlib
diff options
context:
space:
mode:
authorsmill <smill@cuckoo.sh>2016-09-14 19:10:13 +0000
committersmill <smill@cuckoo.sh>2016-09-14 19:10:13 +0000
commit9429f1bc7b33846c71d7c06f92506a4fc4c68049 (patch)
tree9047f9e9a8ec42ad5c7e212cd4944269d66b78c8 /netlib
parentfad6ee6437f89c0b9e914e509b93e97471af9ed6 (diff)
downloadmitmproxy-9429f1bc7b33846c71d7c06f92506a4fc4c68049.tar.gz
mitmproxy-9429f1bc7b33846c71d7c06f92506a4fc4c68049.tar.bz2
mitmproxy-9429f1bc7b33846c71d7c06f92506a4fc4c68049.zip
Prevent crash in case of a connection timeout.
Diffstat (limited to 'netlib')
-rw-r--r--netlib/tcp.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/netlib/tcp.py b/netlib/tcp.py
index c3b8a407..4e988ee3 100644
--- a/netlib/tcp.py
+++ b/netlib/tcp.py
@@ -484,12 +484,14 @@ class _Connection(object):
if not isinstance(self.connection, SSL.Connection):
if not getattr(self.wfile, "closed", False):
try:
- self.wfile.flush()
- self.wfile.close()
+ if self.wfile:
+ self.wfile.flush()
+ self.wfile.close()
except exceptions.TcpDisconnect:
pass
- self.rfile.close()
+ if self.rfile:
+ self.rfile.close()
else:
try:
self.connection.shutdown()