diff options
author | Maximilian Hils <git@maximilianhils.com> | 2017-02-08 11:49:22 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2017-02-09 15:24:31 +0100 |
commit | 9b97b6389127e6166fa0f1ad08951ccdb4a36290 (patch) | |
tree | b30b96546f0e13c56577e31cdf0fdd2e85848fa3 /mitmproxy | |
parent | 2316c0fb74efefd76970c685b8f77f45834f1490 (diff) | |
download | mitmproxy-9b97b6389127e6166fa0f1ad08951ccdb4a36290.tar.gz mitmproxy-9b97b6389127e6166fa0f1ad08951ccdb4a36290.tar.bz2 mitmproxy-9b97b6389127e6166fa0f1ad08951ccdb4a36290.zip |
fix change_upstream_proxy_server
Diffstat (limited to 'mitmproxy')
-rw-r--r-- | mitmproxy/proxy/protocol/http.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/mitmproxy/proxy/protocol/http.py b/mitmproxy/proxy/protocol/http.py index 59de070f..b70afe33 100644 --- a/mitmproxy/proxy/protocol/http.py +++ b/mitmproxy/proxy/protocol/http.py @@ -88,6 +88,10 @@ class UpstreamConnectLayer(base.Layer): layer() def _send_connect_request(self): + self.log("Sending CONNECT request", "debug", [ + "Proxy Server: {}".format(self.ctx.server_conn.address), + "Connect to: {}:{}".format(self.connect_request.host, self.connect_request.port) + ]) self.send_request(self.connect_request) resp = self.read_response(self.connect_request) if resp.status_code != 200: @@ -101,6 +105,7 @@ class UpstreamConnectLayer(base.Layer): pass # swallow the message def change_upstream_proxy_server(self, address): + self.log("Changing upstream proxy to {} (CONNECTed)".format(repr(address)), "debug") if address != self.server_conn.via.address: self.ctx.set_server(address) @@ -432,10 +437,13 @@ class HttpLayer(base.Layer): except (exceptions.NetlibException, h2.exceptions.H2Error, exceptions.Http2ProtocolException): self.log("Failed to send error response to client: {}".format(message), "debug") - def change_upstream_proxy_server(self, address) -> None: + def change_upstream_proxy_server(self, address): # Make set_upstream_proxy_server always available, # even if there's no UpstreamConnectLayer - if address != self.server_conn.address: + if hasattr(self.ctx, "change_upstream_proxy_server"): + self.ctx.change_upstream_proxy_server(address) + elif address != self.server_conn.address: + self.log("Changing upstream proxy to {} (not CONNECTed)".format(repr(address)), "debug") self.set_server(address) def establish_server_connection(self, host: str, port: int, scheme: str): |