diff options
author | Aldo Cortesi <aldo@corte.si> | 2016-11-04 14:58:05 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-04 14:58:05 +1300 |
commit | 4b5ed2c84e9857f87e07bc489bb989ce7fde0511 (patch) | |
tree | b1201510943ccfcd72aa55488f8fa3ca5415fbd3 | |
parent | fd56a7b3ad7e61fd6be61e31051b47a00e2ba6e9 (diff) | |
parent | 067198a5dd5638afdec385be00ba457628d1a154 (diff) | |
download | mitmproxy-4b5ed2c84e9857f87e07bc489bb989ce7fde0511.tar.gz mitmproxy-4b5ed2c84e9857f87e07bc489bb989ce7fde0511.tar.bz2 mitmproxy-4b5ed2c84e9857f87e07bc489bb989ce7fde0511.zip |
Merge pull request #1715 from cortesi/deprecated
Remove deprecated interfaces
-rw-r--r-- | mitmproxy/net/http/__init__.py | 2 | ||||
-rw-r--r-- | mitmproxy/net/http/message.py | 30 | ||||
-rw-r--r-- | mitmproxy/proxy/protocol/http.py | 2 | ||||
-rw-r--r-- | mitmproxy/proxy/protocol/http2.py | 2 | ||||
-rw-r--r-- | pathod/protocols/http2.py | 8 | ||||
-rw-r--r-- | test/mitmproxy/protocol/test_http2.py | 8 |
6 files changed, 10 insertions, 42 deletions
diff --git a/mitmproxy/net/http/__init__.py b/mitmproxy/net/http/__init__.py index 7e290bdc..fd976cd8 100644 --- a/mitmproxy/net/http/__init__.py +++ b/mitmproxy/net/http/__init__.py @@ -2,7 +2,6 @@ from mitmproxy.net.http.request import Request from mitmproxy.net.http.response import Response from mitmproxy.net.http.message import Message from mitmproxy.net.http.headers import Headers, parse_content_type -from mitmproxy.net.http.message import decoded from mitmproxy.net.http import http1, http2, status_codes, multipart __all__ = [ @@ -10,6 +9,5 @@ __all__ = [ "Response", "Message", "Headers", "parse_content_type", - "decoded", "http1", "http2", "status_codes", "multipart", ] diff --git a/mitmproxy/net/http/message.py b/mitmproxy/net/http/message.py index af1d16be..3a243070 100644 --- a/mitmproxy/net/http/message.py +++ b/mitmproxy/net/http/message.py @@ -1,5 +1,4 @@ import re -import warnings from typing import Optional from mitmproxy.utils import strutils @@ -269,32 +268,3 @@ class Message(serializable.Serializable): ) replacements += self.headers.replace(pattern, repl, flags=flags, count=count) return replacements - - # Legacy - - @property - def body(self): # pragma: no cover - warnings.warn(".body is deprecated, use .content instead.", DeprecationWarning) - return self.content - - @body.setter - def body(self, body): # pragma: no cover - warnings.warn(".body is deprecated, use .content instead.", DeprecationWarning) - self.content = body - - -class decoded: - """ - Deprecated: You can now directly use :py:attr:`content`. - :py:attr:`raw_content` has the encoded content. - """ - - def __init__(self, message): # pragma no cover - warnings.warn("decoded() is deprecated, you can now directly use .content instead. " - ".raw_content has the encoded content.", DeprecationWarning) - - def __enter__(self): # pragma no cover - pass - - def __exit__(self, type, value, tb): # pragma no cover - pass diff --git a/mitmproxy/proxy/protocol/http.py b/mitmproxy/proxy/protocol/http.py index 1e2c627e..5412827f 100644 --- a/mitmproxy/proxy/protocol/http.py +++ b/mitmproxy/proxy/protocol/http.py @@ -252,7 +252,7 @@ class HttpLayer(base.Layer): # TODO: We may have to use send_response_headers for HTTP2 here. self.send_response(http.expect_continue_response) request.headers.pop("expect") - request.body = b"".join(self.read_request_body(request)) + request.content = b"".join(self.read_request_body(request)) request.timestamp_end = time.time() return request diff --git a/mitmproxy/proxy/protocol/http2.py b/mitmproxy/proxy/protocol/http2.py index 7a28ac2e..b204f6e8 100644 --- a/mitmproxy/proxy/protocol/http2.py +++ b/mitmproxy/proxy/protocol/http2.py @@ -547,7 +547,7 @@ class Http2SingleStreamLayer(httpbase._HttpTransmissionLayer, basethread.BaseThr self.server_conn.h2.safe_send_body( self.raise_zombie, self.server_stream_id, - [message.body] + [message.content] ) @detect_zombie_stream diff --git a/pathod/protocols/http2.py b/pathod/protocols/http2.py index 118163d2..628e3f33 100644 --- a/pathod/protocols/http2.py +++ b/pathod/protocols/http2.py @@ -190,8 +190,8 @@ class HTTP2StateProtocol: stream_id = self._next_stream_id() return list(itertools.chain( - self._create_headers(headers, stream_id, end_stream=(request.body is None or len(request.body) == 0)), - self._create_body(request.body, stream_id))) + self._create_headers(headers, stream_id, end_stream=(request.content is None or len(request.content) == 0)), + self._create_body(request.content, stream_id))) def assemble_response(self, response): assert isinstance(response, mitmproxy.net.http.response.Response) @@ -207,8 +207,8 @@ class HTTP2StateProtocol: stream_id = self._next_stream_id() return list(itertools.chain( - self._create_headers(headers, stream_id, end_stream=(response.body is None or len(response.body) == 0)), - self._create_body(response.body, stream_id), + self._create_headers(headers, stream_id, end_stream=(response.content is None or len(response.content) == 0)), + self._create_body(response.content, stream_id), )) def perform_connection_preface(self, force=False): diff --git a/test/mitmproxy/protocol/test_http2.py b/test/mitmproxy/protocol/test_http2.py index a2eeea52..e4283e3f 100644 --- a/test/mitmproxy/protocol/test_http2.py +++ b/test/mitmproxy/protocol/test_http2.py @@ -273,7 +273,7 @@ class TestSimple(_Http2Test): assert self.master.state.flows[0].response.status_code == 200 assert self.master.state.flows[0].response.headers['server-foo'] == 'server-bar' assert self.master.state.flows[0].response.headers['föo'] == 'bär' - assert self.master.state.flows[0].response.body == b'response body' + assert self.master.state.flows[0].response.content == b'response body' assert self.request_body_buffer == b'request body' assert response_body_buffer == b'response body' @@ -731,7 +731,7 @@ class TestPushPromise(_Http2Test): assert ended_streams == 3 assert pushed_streams == 2 - bodies = [flow.response.body for flow in self.master.state.flows] + bodies = [flow.response.content for flow in self.master.state.flows] assert len(bodies) == 3 assert b'regular_stream' in bodies assert b'pushed_stream_foo' in bodies @@ -783,7 +783,7 @@ class TestPushPromise(_Http2Test): client.wfile.write(h2_conn.data_to_send()) client.wfile.flush() - bodies = [flow.response.body for flow in self.master.state.flows if flow.response] + bodies = [flow.response.content for flow in self.master.state.flows if flow.response] assert len(bodies) >= 1 assert b'regular_stream' in bodies # the other two bodies might not be transmitted before the reset @@ -889,7 +889,7 @@ class TestMaxConcurrentStreams(_Http2Test): assert len(self.master.state.flows) == len(new_streams) for flow in self.master.state.flows: assert flow.response.status_code == 200 - assert b"Stream-ID " in flow.response.body + assert b"Stream-ID " in flow.response.content @requires_alpn |