mirror of
https://github.com/django/daphne.git
synced 2025-03-13 03:45:45 +03:00
Add warning for non-bytes HTTP status messages
This commit is contained in:
parent
f76984ec69
commit
33ce841d29
|
@ -1,7 +1,9 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import time
|
|
||||||
import logging
|
import logging
|
||||||
|
import six
|
||||||
|
import time
|
||||||
|
|
||||||
from twisted.python.compat import _PY3
|
from twisted.python.compat import _PY3
|
||||||
from twisted.web import http
|
from twisted.web import http
|
||||||
from twisted.protocols.policies import ProtocolWrapper
|
from twisted.protocols.policies import ProtocolWrapper
|
||||||
|
@ -113,7 +115,11 @@ class WebRequest(http.Request):
|
||||||
raise ValueError("Got multiple Response messages!")
|
raise ValueError("Got multiple Response messages!")
|
||||||
self._got_response_start = True
|
self._got_response_start = True
|
||||||
# Write code
|
# Write code
|
||||||
self.setResponseCode(message['status'], message.get("status_text", None))
|
status_text = message.get("status_text", None)
|
||||||
|
if isinstance(status_text, six.text_type):
|
||||||
|
logger.warn("HTTP status text for %s was text - should be bytes", self.reply_channel)
|
||||||
|
status_text = status_text.encode("ascii")
|
||||||
|
self.setResponseCode(message['status'], )
|
||||||
# Write headers
|
# Write headers
|
||||||
for header, value in message.get("headers", {}):
|
for header, value in message.get("headers", {}):
|
||||||
self.setHeader(header.encode("utf8"), value)
|
self.setHeader(header.encode("utf8"), value)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user