mirror of
https://github.com/django/daphne.git
synced 2024-11-28 02:33:43 +03:00
Response chunk support
This commit is contained in:
parent
0f5fe8b274
commit
c61664dd3c
|
@ -29,6 +29,7 @@ class WebRequest(http.Request):
|
|||
# Tell factory we're that channel's client
|
||||
self.last_keepalive = time.time()
|
||||
self.factory.reply_protocols[self.reply_channel] = self
|
||||
self._got_response_start = False
|
||||
|
||||
def process(self):
|
||||
# Get upgrade header
|
||||
|
@ -104,6 +105,10 @@ class WebRequest(http.Request):
|
|||
"""
|
||||
Writes a received HTTP response back out to the transport.
|
||||
"""
|
||||
if "status" in message:
|
||||
if self._got_response_start:
|
||||
raise ValueError("Got multiple Response messages!")
|
||||
self._got_response_start = True
|
||||
# Write code
|
||||
self.setResponseCode(message['status'])
|
||||
# Write headers
|
||||
|
@ -112,8 +117,12 @@ class WebRequest(http.Request):
|
|||
# Write out body
|
||||
if "content" in message:
|
||||
http.Request.write(self, message['content'].encode("utf8"))
|
||||
# End if there's no more content
|
||||
if not message.get("more_content", False):
|
||||
self.finish()
|
||||
logging.debug("HTTP %s response for %s", message['status'], self.reply_channel)
|
||||
else:
|
||||
logging.debug("HTTP %s response chunk for %s", message['status'], self.reply_channel)
|
||||
|
||||
|
||||
class HTTPProtocol(http.HTTPChannel):
|
||||
|
|
Loading…
Reference in New Issue
Block a user