diff options
-rw-r--r-- | docs/src/content/howto-kubernetes.md | 13 | ||||
-rw-r--r-- | mitmproxy/net/http/response.py | 8 | ||||
-rw-r--r-- | test/mitmproxy/net/http/test_response.py | 6 |
3 files changed, 25 insertions, 2 deletions
diff --git a/docs/src/content/howto-kubernetes.md b/docs/src/content/howto-kubernetes.md new file mode 100644 index 00000000..1276ec91 --- /dev/null +++ b/docs/src/content/howto-kubernetes.md @@ -0,0 +1,13 @@ +--- +title: "Kubernetes Services" +menu: + howto: + weight: 1 +--- + +# Kubernetes Services + +The [github.com/soluble-ai/kubetap](https://github.com/soluble-ai/kubetap) project +provides a kubectl plugin for easily deploying mitmproxy to proxy Kubernetes Services. + +For usage and documentation, please refer to the [kubetap project site](https://soluble-ai.github.io/kubetap/). diff --git a/mitmproxy/net/http/response.py b/mitmproxy/net/http/response.py index 2e864405..c4dbf408 100644 --- a/mitmproxy/net/http/response.py +++ b/mitmproxy/net/http/response.py @@ -122,10 +122,14 @@ class Response(message.Message): def reason(self): """ HTTP Reason Phrase, e.g. "Not Found". - This is always :py:obj:`None` for HTTP2 requests, because HTTP2 responses do not contain a reason phrase. + HTTP2 responses do not contain a reason phrase and self.data.reason will be :py:obj:`None`. + When :py:obj:`None` return an empty reason phrase so that functions expecting a string work properly. """ # Encoding: http://stackoverflow.com/a/16674906/934719 - return self.data.reason.decode("ISO-8859-1", "surrogateescape") + if self.data.reason is not None: + return self.data.reason.decode("ISO-8859-1", "surrogateescape") + else: + return "" @reason.setter def reason(self, reason): diff --git a/test/mitmproxy/net/http/test_response.py b/test/mitmproxy/net/http/test_response.py index 27c16be6..08d72840 100644 --- a/test/mitmproxy/net/http/test_response.py +++ b/test/mitmproxy/net/http/test_response.py @@ -77,6 +77,12 @@ class TestResponseCore: resp.data.reason = b'cr\xe9e' assert resp.reason == "crée" + # HTTP2 responses do not contain a reason phrase and self.data.reason will be None. + # This should render to an empty reason phrase so that functions + # expecting a string work properly. + resp.data.reason = None + assert resp.reason == "" + class TestResponseUtils: """ |