Revert "Replaced COMMON_STATUS_CODES with a simple 200 check for more fast"
This reverts commit 15b6980
This commit is contained in:
parent
15b6980a1a
commit
d8df095d1c
|
@ -1,4 +1,4 @@
|
|||
from sanic.response import STATUS_CODES
|
||||
from sanic.response import ALL_STATUS_CODES, COMMON_STATUS_CODES
|
||||
|
||||
TRACEBACK_STYLE = '''
|
||||
<style>
|
||||
|
@ -275,7 +275,8 @@ def abort(status_code, message=None):
|
|||
in response.py for the given status code.
|
||||
"""
|
||||
if message is None:
|
||||
message = STATUS_CODES.get(status_code)
|
||||
message = COMMON_STATUS_CODES.get(status_code,
|
||||
ALL_STATUS_CODES.get(status_code))
|
||||
# These are stored as bytes in the STATUS_CODES dict
|
||||
message = message.decode('utf8')
|
||||
sanic_exception = _sanic_exceptions.get(status_code, SanicException)
|
||||
|
|
|
@ -10,7 +10,13 @@ from aiofiles import open as open_async
|
|||
|
||||
from sanic.cookies import CookieJar
|
||||
|
||||
STATUS_CODES = {
|
||||
COMMON_STATUS_CODES = {
|
||||
200: b'OK',
|
||||
400: b'Bad Request',
|
||||
404: b'Not Found',
|
||||
500: b'Internal Server Error',
|
||||
}
|
||||
ALL_STATUS_CODES = {
|
||||
100: b'Continue',
|
||||
101: b'Switching Protocols',
|
||||
102: b'Processing',
|
||||
|
@ -156,10 +162,11 @@ class StreamingHTTPResponse(BaseHTTPResponse):
|
|||
|
||||
headers = self._parse_headers()
|
||||
|
||||
if self.status is 200:
|
||||
status = b'OK'
|
||||
else:
|
||||
status = STATUS_CODES.get(self.status)
|
||||
# Try to pull from the common codes first
|
||||
# Speeds up response rate 6% over pulling from all
|
||||
status = COMMON_STATUS_CODES.get(self.status)
|
||||
if not status:
|
||||
status = ALL_STATUS_CODES.get(self.status)
|
||||
|
||||
return (b'HTTP/%b %d %b\r\n'
|
||||
b'%b'
|
||||
|
@ -202,10 +209,11 @@ class HTTPResponse(BaseHTTPResponse):
|
|||
|
||||
headers = self._parse_headers()
|
||||
|
||||
if self.status is 200:
|
||||
status = b'OK'
|
||||
else:
|
||||
status = STATUS_CODES.get(self.status, b'UNKNOWN RESPONSE')
|
||||
# Try to pull from the common codes first
|
||||
# Speeds up response rate 6% over pulling from all
|
||||
status = COMMON_STATUS_CODES.get(self.status)
|
||||
if not status:
|
||||
status = ALL_STATUS_CODES.get(self.status, b'UNKNOWN RESPONSE')
|
||||
|
||||
return (b'HTTP/%b %d %b\r\n'
|
||||
b'Connection: %b\r\n'
|
||||
|
|
Loading…
Reference in New Issue
Block a user