aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/proxy/protocol/http.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-11-04 10:54:04 +1300
committerAldo Cortesi <aldo@nullcube.com>2016-11-04 10:59:41 +1300
commit4eb2b56dec09bf3e7322e402ad5ba46523309138 (patch)
treedc506686e58750b9a6e394fbc78473d9e9792d22 /mitmproxy/proxy/protocol/http.py
parent6c8c4465d9971076e9a04f8042aebd5d71f67d59 (diff)
downloadmitmproxy-4eb2b56dec09bf3e7322e402ad5ba46523309138.tar.gz
mitmproxy-4eb2b56dec09bf3e7322e402ad5ba46523309138.tar.bz2
mitmproxy-4eb2b56dec09bf3e7322e402ad5ba46523309138.zip
Let's not over-ride __bool__ on connection objects
If I had a thousand years and every thesaurus in the world, I still couldn't adequately express how much I dislike this piece of interface design.
Diffstat (limited to 'mitmproxy/proxy/protocol/http.py')
-rw-r--r--mitmproxy/proxy/protocol/http.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/mitmproxy/proxy/protocol/http.py b/mitmproxy/proxy/protocol/http.py
index 542f6a94..1e2c627e 100644
--- a/mitmproxy/proxy/protocol/http.py
+++ b/mitmproxy/proxy/protocol/http.py
@@ -76,8 +76,8 @@ class ConnectServerConnection:
def __getattr__(self, item):
return getattr(self.via, item)
- def __bool__(self):
- return bool(self.via)
+ def connected(self):
+ return self.via.connected()
class UpstreamConnectLayer(base.Layer):
@@ -101,7 +101,7 @@ class UpstreamConnectLayer(base.Layer):
raise exceptions.ProtocolException("Reconnect: Upstream server refuses CONNECT request")
def connect(self):
- if not self.server_conn:
+ if not self.server_conn.connected():
self.ctx.connect()
self._send_connect_request()
else:
@@ -112,7 +112,7 @@ class UpstreamConnectLayer(base.Layer):
self.ctx.set_server(address)
def set_server(self, address):
- if self.ctx.server_conn:
+ if self.ctx.server_conn.connected():
self.ctx.disconnect()
address = tcp.Address.wrap(address)
self.connect_request.host = address.host
@@ -378,10 +378,10 @@ class HttpLayer(base.Layer):
self.set_server(address)
self.set_server_tls(tls, address.host)
# Establish connection is neccessary.
- if not self.server_conn:
+ if not self.server_conn.connected():
self.connect()
else:
- if not self.server_conn:
+ if not self.server_conn.connected():
self.connect()
if tls:
raise exceptions.HttpProtocolException("Cannot change scheme in upstream proxy mode.")