Extend pseudo-header treatment to :status on responses

This commit is contained in:
Aldo Cortesi 2016-05-31 15:12:20 +12:00
parent 9ea68ebd28
commit 4de4223b2d
1 changed files with 6 additions and 2 deletions

View File

@ -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")