diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-09-10 10:20:11 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-09-10 10:20:11 +0200 |
commit | cf2b2e0cc71b34d851503852544eed3cd5442ca0 (patch) | |
tree | 9f21c2b6a69c8dc6c7730402c96d1d4d4ac15663 /libmproxy/protocol/http.py | |
parent | 61f4319491ccc9a6c2dff84eaebe628014987148 (diff) | |
download | mitmproxy-cf2b2e0cc71b34d851503852544eed3cd5442ca0.tar.gz mitmproxy-cf2b2e0cc71b34d851503852544eed3cd5442ca0.tar.bz2 mitmproxy-cf2b2e0cc71b34d851503852544eed3cd5442ca0.zip |
simplify streaming http layer
Diffstat (limited to 'libmproxy/protocol/http.py')
-rw-r--r-- | libmproxy/protocol/http.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index dbe91e3c..a05f3597 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -45,12 +45,23 @@ class _StreamingHttpLayer(_HttpLayer): raise NotImplementedError() yield "this is a generator" # pragma: no cover + def read_response(self, request_method): + response = self.read_response_headers() + response.body = "".join( + self.read_response_body(response.headers, request_method, response.code) + ) + return response + def send_response_headers(self, response): raise NotImplementedError def send_response_body(self, response, chunks): raise NotImplementedError() + def send_response(self, response): + self.send_response_headers(response) + self.send_response_body(response, response.body) + class Http1Layer(_StreamingHttpLayer): def __init__(self, ctx, mode): @@ -68,17 +79,6 @@ class Http1Layer(_StreamingHttpLayer): def send_request(self, request): self.server_conn.send(self.server_protocol.assemble(request)) - def read_response(self, request_method): - return HTTPResponse.from_protocol( - self.server_protocol, - request_method=request_method, - body_size_limit=self.config.body_size_limit, - include_body=True - ) - - def send_response(self, response): - self.client_conn.send(self.client_protocol.assemble(response)) - def read_response_headers(self): return HTTPResponse.from_protocol( self.server_protocol, |