diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2015-07-17 09:37:57 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2015-07-22 15:30:51 +0200 |
commit | 4617ab8a3a981f3abd8d62b561c80f9ad141e57b (patch) | |
tree | 714bedbc37b482f4b24019f910309d48aaa5a2c1 /netlib/http/http1/protocol.py | |
parent | 808b294865257fc3f52b33ed2a796009658b126f (diff) | |
download | mitmproxy-4617ab8a3a981f3abd8d62b561c80f9ad141e57b.tar.gz mitmproxy-4617ab8a3a981f3abd8d62b561c80f9ad141e57b.tar.bz2 mitmproxy-4617ab8a3a981f3abd8d62b561c80f9ad141e57b.zip |
add Request class and unify read_request interface
Diffstat (limited to 'netlib/http/http1/protocol.py')
-rw-r--r-- | netlib/http/http1/protocol.py | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/netlib/http/http1/protocol.py b/netlib/http/http1/protocol.py index 401654c1..8d631a13 100644 --- a/netlib/http/http1/protocol.py +++ b/netlib/http/http1/protocol.py @@ -11,25 +11,10 @@ from ..exceptions import * class HTTP1Protocol(object): - # TODO: make this a regular class - just like Response - Request = collections.namedtuple( - "Request", - [ - "form_in", - "method", - "scheme", - "host", - "port", - "path", - "httpversion", - "headers", - "content" - ] - ) - def __init__(self, tcp_handler): self.tcp_handler = tcp_handler + def get_request_line(self): """ Get a line, possibly preceded by a blank. @@ -40,6 +25,7 @@ class HTTP1Protocol(object): line = self.tcp_handler.rfile.readline() return line + def read_headers(self): """ Read a set of headers. @@ -175,6 +161,7 @@ class HTTP1Protocol(object): return None return host, port, httpversion + @classmethod def parse_init_proxy(self, line): v = self.parse_init(line) @@ -188,6 +175,7 @@ class HTTP1Protocol(object): scheme, host, port, path = parts return method, scheme, host, port, path, httpversion + @classmethod def parse_init_http(self, line): """ @@ -425,7 +413,7 @@ class HTTP1Protocol(object): True ) - return self.Request( + return http.Request( form_in, method, scheme, |