aboutsummaryrefslogtreecommitdiffstats
path: root/netlib
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-09-22 01:58:01 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-09-22 01:58:01 -0700
commite5b79a6d728584cceb918ffbf73c54ec55e948b5 (patch)
treee6f31c3dc4772ff3225f8aba2784d89302feafca /netlib
parentec588f88221edb19137209a66431fdf4517c215c (diff)
downloadmitmproxy-e5b79a6d728584cceb918ffbf73c54ec55e948b5.tar.gz
mitmproxy-e5b79a6d728584cceb918ffbf73c54ec55e948b5.tar.bz2
mitmproxy-e5b79a6d728584cceb918ffbf73c54ec55e948b5.zip
minor cleanup
Diffstat (limited to 'netlib')
-rw-r--r--netlib/exceptions.py4
-rw-r--r--netlib/tcp.py17
2 files changed, 6 insertions, 15 deletions
diff --git a/netlib/exceptions.py b/netlib/exceptions.py
index 37651409..dec79c22 100644
--- a/netlib/exceptions.py
+++ b/netlib/exceptions.py
@@ -58,7 +58,3 @@ class InvalidCertificateException(TlsException):
class Timeout(TcpException):
pass
-
-
-class ProtocolException(NetlibException):
- pass
diff --git a/netlib/tcp.py b/netlib/tcp.py
index 2c55de85..eea10425 100644
--- a/netlib/tcp.py
+++ b/netlib/tcp.py
@@ -484,14 +484,12 @@ class _Connection(object):
if not isinstance(self.connection, SSL.Connection):
if not getattr(self.wfile, "closed", False):
try:
- if self.wfile:
- self.wfile.flush()
- self.wfile.close()
+ self.wfile.flush()
+ self.wfile.close()
except exceptions.TcpDisconnect:
pass
- if self.rfile:
- self.rfile.close()
+ self.rfile.close()
else:
try:
self.connection.shutdown()
@@ -731,11 +729,7 @@ class TCPClient(_Connection):
def connect(self):
try:
- # Allow the socket to be manipulated by using the server_conn stub.
- if not self.connection:
- connection = socket.socket(self.address.family, socket.SOCK_STREAM)
- else:
- connection = self.connection
+ connection = socket.socket(self.address.family, socket.SOCK_STREAM)
if self.spoof_source_address:
try:
@@ -744,7 +738,8 @@ class TCPClient(_Connection):
connection.setsockopt(socket.SOL_IP, 19, 1)
except socket.error as e:
raise exceptions.TcpException(
- "Failed to spoof the source address: " + e.strerror)
+ "Failed to spoof the source address: " + e.strerror
+ )
if self.source_address:
connection.bind(self.source_address())
connection.connect(self.address())