diff options
author | Thomas Kriechbaumer <Kriechi@users.noreply.github.com> | 2020-06-08 19:35:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-08 19:35:32 +0200 |
commit | bbc2cf331a4ab180001668bf4b51eeec505e01ab (patch) | |
tree | c11995d5a3b43252d741ed8bbd66cf47379e8d02 /mitmproxy/net/http/response.py | |
parent | 107b019b05798f97d2a0de8ef866ea6197975d9f (diff) | |
parent | 75ec05c85e597e66128c68c124f8a0376a5db7f2 (diff) | |
download | mitmproxy-bbc2cf331a4ab180001668bf4b51eeec505e01ab.tar.gz mitmproxy-bbc2cf331a4ab180001668bf4b51eeec505e01ab.tar.bz2 mitmproxy-bbc2cf331a4ab180001668bf4b51eeec505e01ab.zip |
Merge pull request #4023 from rbdixon/http2_response_fix
HTTP2 response reason is None, render as '' in property.
Diffstat (limited to 'mitmproxy/net/http/response.py')
-rw-r--r-- | mitmproxy/net/http/response.py | 8 |
1 files changed, 6 insertions, 2 deletions
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): |