Skip to content

Commit

Permalink
Rename the http module to helpers to prevent conflicts with the b…
Browse files Browse the repository at this point in the history
…uilt-in Python http library (fixes #1323)
  • Loading branch information
hatarist committed Sep 25, 2018
1 parent 04b8dd9 commit f8a6af1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sanic/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sanic.http import STATUS_CODES
from sanic.helpers import STATUS_CODES

TRACEBACK_STYLE = '''
<style>
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions sanic/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from aiofiles import open as open_async
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


Expand Down Expand Up @@ -103,7 +103,7 @@ def get_headers(
if self.status is 200:
status = b'OK'
else:
status = http.STATUS_CODES.get(self.status)
status = STATUS_CODES.get(self.status)

return (b'HTTP/%b %d %b\r\n'
b'%b'
Expand Down Expand Up @@ -141,7 +141,7 @@ def output(
timeout_header = b'Keep-Alive: %d\r\n' % keep_alive_timeout

body = b''
if http.has_message_body(self.status):
if has_message_body(self.status):
body = self.body
self.headers['Content-Length'] = self.headers.get(
'Content-Length', len(self.body))
Expand All @@ -150,14 +150,14 @@ def output(
'Content-Type', self.content_type)

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()

if self.status is 200:
status = b'OK'
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'
b'Connection: %b\r\n'
Expand Down

0 comments on commit f8a6af1

Please sign in to comment.