Merge pull request #1327 from hatarist/fix-1323

Rename the `http` module to `helpers`
This commit is contained in:
Stephen Sadowski 2018-10-11 07:56:51 -05:00 committed by GitHub
commit fd61b9e3e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -1,4 +1,4 @@
from sanic.http import STATUS_CODES from sanic.helpers import STATUS_CODES
TRACEBACK_STYLE = ''' TRACEBACK_STYLE = '''
<style> <style>

View File

@ -10,7 +10,7 @@ except BaseException:
from aiofiles import open as open_async from aiofiles import open as open_async
from multidict import CIMultiDict from multidict import CIMultiDict
from sanic import http from sanic.helpers import STATUS_CODES, has_message_body, remove_entity_headers
from sanic.cookies import CookieJar from sanic.cookies import CookieJar
@ -103,7 +103,7 @@ class StreamingHTTPResponse(BaseHTTPResponse):
if self.status is 200: if self.status is 200:
status = b'OK' status = b'OK'
else: else:
status = http.STATUS_CODES.get(self.status) status = STATUS_CODES.get(self.status)
return (b'HTTP/%b %d %b\r\n' return (b'HTTP/%b %d %b\r\n'
b'%b' b'%b'
@ -141,7 +141,7 @@ class HTTPResponse(BaseHTTPResponse):
timeout_header = b'Keep-Alive: %d\r\n' % keep_alive_timeout timeout_header = b'Keep-Alive: %d\r\n' % keep_alive_timeout
body = b'' body = b''
if http.has_message_body(self.status): if has_message_body(self.status):
body = self.body body = self.body
self.headers['Content-Length'] = self.headers.get( self.headers['Content-Length'] = self.headers.get(
'Content-Length', len(self.body)) 'Content-Length', len(self.body))
@ -150,14 +150,14 @@ class HTTPResponse(BaseHTTPResponse):
'Content-Type', self.content_type) 'Content-Type', self.content_type)
if self.status in (304, 412): if self.status in (304, 412):
self.headers = http.remove_entity_headers(self.headers) self.headers = remove_entity_headers(self.headers)
headers = self._parse_headers() headers = self._parse_headers()
if self.status is 200: if self.status is 200:
status = b'OK' status = b'OK'
else: else:
status = http.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' return (b'HTTP/%b %d %b\r\n'
b'Connection: %b\r\n' b'Connection: %b\r\n'