diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2013-01-04 14:19:32 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2013-01-04 14:19:32 +1300 |
commit | 46ab6ed4912039e19c17cc4346bf562f2acdc8a9 (patch) | |
tree | bfaf607742c44e0771516f7f2b50596595885829 /libmproxy | |
parent | f5e49ef598f46257cc783e52ef4223a3461f1d84 (diff) | |
download | mitmproxy-46ab6ed4912039e19c17cc4346bf562f2acdc8a9.tar.gz mitmproxy-46ab6ed4912039e19c17cc4346bf562f2acdc8a9.tar.bz2 mitmproxy-46ab6ed4912039e19c17cc4346bf562f2acdc8a9.zip |
Minor cleanups of proxy request handling.
Diffstat (limited to 'libmproxy')
-rw-r--r-- | libmproxy/proxy.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 22e7ff63..da47dc20 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -51,6 +51,7 @@ class ProxyConfig: self.transparent_proxy = transparent_proxy self.authenticator = authenticator + class RequestReplayThread(threading.Thread): def __init__(self, config, flow, masterq): self.config, self.flow, self.masterq = config, flow, masterq @@ -311,7 +312,7 @@ class ProxyHandler(tcp.BaseHandler): line = self.get_line(self.rfile) if line == "": return None - if line.startswith("CONNECT"): + if http.parse_init_connect(line): r = http.parse_init_connect(line) if not r: raise ProxyError(400, "Bad HTTP request line: %s"%repr(line)) @@ -332,14 +333,15 @@ class ProxyHandler(tcp.BaseHandler): raise ProxyError(400, str(v)) self.proxy_connect_state = (host, port, httpversion) line = self.rfile.readline(line) + if self.proxy_connect_state: - host, port, httpversion = self.proxy_connect_state r = http.parse_init_http(line) if not r: raise ProxyError(400, "Bad HTTP request line: %s"%repr(line)) method, path, httpversion = r headers = self.read_headers(authenticate=False) + host, port, _ = self.proxy_connect_state content = http.read_http_body_request( self.rfile, self.wfile, headers, httpversion, self.config.body_size_limit ) @@ -348,7 +350,7 @@ class ProxyHandler(tcp.BaseHandler): r = http.parse_init_proxy(line) if not r: raise ProxyError(400, "Bad HTTP request line: %s"%repr(line)) - method, scheme, host, port, path, httpversion = http.parse_init_proxy(line) + method, scheme, host, port, path, httpversion = r headers = self.read_headers(authenticate=True) content = http.read_http_body_request( self.rfile, self.wfile, headers, httpversion, self.config.body_size_limit |