diff options
-rw-r--r-- | libmproxy/proxy.py | 8 | ||||
-rw-r--r-- | test/tutils.py | 4 |
2 files changed, 7 insertions, 5 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 diff --git a/test/tutils.py b/test/tutils.py index 0e661a4b..479482ac 100644 --- a/test/tutils.py +++ b/test/tutils.py @@ -4,7 +4,7 @@ from contextlib import contextmanager from libmproxy import proxy, flow, controller, utils from netlib import certutils import human_curl as hurl -import libpathod.test +import libpathod.test, libpathod.pathoc def treq(conn=None): if not conn: @@ -194,7 +194,6 @@ class ReverseProxTest(ProxTestBase): return r - @contextmanager def tmpdir(*args, **kwargs): orig_workdir = os.getcwd() @@ -244,5 +243,6 @@ def raises(exc, obj, *args, **kwargs): ) ) raise AssertionError("No exception raised.") + test_data = utils.Data(__name__) |