aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-05-31 15:12:20 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-05-31 15:12:20 +1200
commit4de4223b2ddb4417be0d6a2fa0556d531a494091 (patch)
tree5139eb975211295b65da9cc9736d92cd1ac0f756
parent9ea68ebd284ce13d765519a20dd7cfe998c0ae1c (diff)
downloadmitmproxy-4de4223b2ddb4417be0d6a2fa0556d531a494091.tar.gz
mitmproxy-4de4223b2ddb4417be0d6a2fa0556d531a494091.tar.bz2
mitmproxy-4de4223b2ddb4417be0d6a2fa0556d531a494091.zip
Extend pseudo-header treatment to :status on responses
-rw-r--r--mitmproxy/protocol/http2.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/mitmproxy/protocol/http2.py b/mitmproxy/protocol/http2.py
index bdc85128..b4101676 100644
--- a/mitmproxy/protocol/http2.py
+++ b/mitmproxy/protocol/http2.py
@@ -387,12 +387,14 @@ class Http2SingleStreamLayer(_HttpTransmissionLayer, threading.Thread):
self.response_arrived.wait()
status_code = int(self.response_headers.get(':status', 502))
+ headers = self.response_headers.copy()
+ headers.clear(":status")
return HTTPResponse(
http_version=b"HTTP/2.0",
status_code=status_code,
reason='',
- headers=self.response_headers,
+ headers=headers,
content=None,
timestamp_start=self.timestamp_start,
timestamp_end=self.timestamp_end,
@@ -412,10 +414,12 @@ class Http2SingleStreamLayer(_HttpTransmissionLayer, threading.Thread):
raise Http2ProtocolException("Zombie Stream")
def send_response_headers(self, response):
+ headers = response.headers.copy()
+ headers.insert(0, ":status", str(response.status_code))
self.client_conn.h2.safe_send_headers(
self.is_zombie,
self.client_stream_id,
- response.headers
+ headers
)
if self.zombie: # pragma: no cover
raise Http2ProtocolException("Zombie Stream")