aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/protocols/http.py
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2015-07-18 15:54:29 +0200
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2015-07-22 15:30:34 +0200
commit6d5a3da9294d5bc6758ded173729042573c9fe5f (patch)
treed2c7993787d4fb7d703bd90f2403ad69b548b186 /libpathod/protocols/http.py
parentcaaac5cd5a48d2bd1e50f0ff88c9d73a20ec9aa6 (diff)
downloadmitmproxy-6d5a3da9294d5bc6758ded173729042573c9fe5f.tar.gz
mitmproxy-6d5a3da9294d5bc6758ded173729042573c9fe5f.tar.bz2
mitmproxy-6d5a3da9294d5bc6758ded173729042573c9fe5f.zip
use new HTTP/1 protocol
Diffstat (limited to 'libpathod/protocols/http.py')
-rw-r--r--libpathod/protocols/http.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/libpathod/protocols/http.py b/libpathod/protocols/http.py
index 363af0fe..43ef0799 100644
--- a/libpathod/protocols/http.py
+++ b/libpathod/protocols/http.py
@@ -6,6 +6,9 @@ class HTTPProtocol:
def __init__(self, pathod_handler):
self.pathod_handler = pathod_handler
+ self.wire_protocol = http1.HTTP1Protocol(
+ self.pathod_handler
+ )
def make_error_response(self, reason, body):
return language.http.make_error_response(reason, body)
@@ -38,7 +41,7 @@ class HTTPProtocol:
"""
Handle a CONNECT request.
"""
- http1.read_headers(self.pathod_handler.rfile)
+ self.wire_protocol.read_headers()
self.pathod_handler.wfile.write(
'HTTP/1.1 200 Connection established\r\n' +
('Proxy-agent: %s\r\n' % version.NAMEVERSION) +
@@ -66,32 +69,31 @@ class HTTPProtocol:
return self.pathod_handler.handle_http_request, None
def read_request(self, lg):
- line = http1.get_request_line(self.pathod_handler.rfile)
+ line = self.wire_protocol.get_request_line()
if not line:
# Normal termination
return dict()
m = utils.MemBool()
- if m(http1.parse_init_connect(line)):
+ if m(self.wire_protocol.parse_init_connect(line)):
return dict(next_handle=self.handle_http_connect(m.v, lg))
- elif m(http1.parse_init_proxy(line)):
+ elif m(self.wire_protocol.parse_init_proxy(line)):
method, _, _, _, path, httpversion = m.v
- elif m(http1.parse_init_http(line)):
+ elif m(self.wire_protocol.parse_init_http(line)):
method, path, httpversion = m.v
else:
s = "Invalid first line: %s" % repr(line)
lg(s)
return dict(errors=dict(type="error", msg=s))
- headers = http1.read_headers(self.pathod_handler.rfile)
+ headers = self.wire_protocol.read_headers()
if headers is None:
s = "Invalid headers"
lg(s)
return dict(errors=dict(type="error", msg=s))
try:
- body = http1.read_http_body(
- self.pathod_handler.rfile,
+ body = self.wire_protocol.read_http_body(
headers,
None,
method,