Simplify status code to text lookup (#1738)

This commit is contained in:
Liran Nuna 2020-01-10 06:43:44 -08:00 committed by Stephen Sadowski
parent 784d5cce52
commit 865536c5c4

View File

@ -118,12 +118,7 @@ class StreamingHTTPResponse(BaseHTTPResponse):
)
headers = self._parse_headers()
if self.status == 200:
status = b"OK"
else:
status = STATUS_CODES.get(self.status)
status = STATUS_CODES.get(self.status, b"UNKNOWN RESPONSE")
return (b"HTTP/%b %d %b\r\n" b"%b" b"%b\r\n") % (
version.encode(),
self.status,
@ -177,12 +172,7 @@ class HTTPResponse(BaseHTTPResponse):
self.headers = remove_entity_headers(self.headers)
headers = self._parse_headers()
if self.status == 200:
status = b"OK"
else:
status = STATUS_CODES.get(self.status, b"UNKNOWN RESPONSE")
status = STATUS_CODES.get(self.status, b"UNKNOWN RESPONSE")
return (
b"HTTP/%b %d %b\r\n" b"Connection: %b\r\n" b"%b" b"%b\r\n" b"%b"
) % (