diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-07-27 03:28:23 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-07-27 03:28:23 +0200 |
commit | c9be57b6828ac06e7ec105cba15560fb2c83030e (patch) | |
tree | d4351e822163bc92d1385701936c68648c5e0ff9 /libmproxy/protocol | |
parent | 2b31a9c49e8dab2955121a7d748f4a73837e4267 (diff) | |
download | mitmproxy-c9be57b6828ac06e7ec105cba15560fb2c83030e.tar.gz mitmproxy-c9be57b6828ac06e7ec105cba15560fb2c83030e.tar.bz2 mitmproxy-c9be57b6828ac06e7ec105cba15560fb2c83030e.zip |
fix #313
Diffstat (limited to 'libmproxy/protocol')
-rw-r--r-- | libmproxy/protocol/http.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index f671816f..21fc2798 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -930,9 +930,14 @@ class HTTPHandler(ProtocolHandler, TemporaryServerChangeMixin): if (http.connection_close(flow.request.httpversion, flow.request.headers) or http.connection_close(flow.response.httpversion, flow.response.headers)): - return False + if flow.request.form_in == "authority" and flow.response.code == 200: + # Workaround for https://github.com/mitmproxy/mitmproxy/issues/313: + # Some proxies (e.g. Charles) send a CONNECT response with HTTP/1.0 and no Content-Length header + pass + else: + return False - if flow.request.form_in == "authority": + if flow.request.form_in == "authority" and flow.response.code == 200: self.ssl_upgrade() # If the user has changed the target server on this connection, @@ -1039,6 +1044,7 @@ class HTTPHandler(ProtocolHandler, TemporaryServerChangeMixin): flow.server_conn = self.c.server_conn # Update server_conn attribute on the flow self.c.client_conn.send( 'HTTP/1.1 200 Connection established\r\n' + + 'Content-Length: 0\r\n' + ('Proxy-agent: %s\r\n' % self.c.server_version) + '\r\n' ) |