Fix: Always call Request.write()

The spec says 'content' is an optional key, defaulting to b''.
But before this commit, if 'content' wasn't specified, Request.write()
was not called. In conjunction with setting 'more_content' to True,
this would result in nothing being written on the transport. If
'content' was set to b'' instead, the HTTP preamble and any headers were
written as expected. That smells like a bug, so I'm making sure we're
always calling Request.write().
This commit is contained in:
Maik Hoepfel 2017-03-21 13:20:57 +08:00
parent 04118cab7e
commit 129fe71f83

View File

@ -240,9 +240,10 @@ class WebRequest(http.Request):
header = header.encode("latin1")
self.responseHeaders.addRawHeader(header, value)
logger.debug("HTTP %s response started for %s", message['status'], self.reply_channel)
# Write out body
if "content" in message:
http.Request.write(self, message['content'])
http.Request.write(self, message.get('content', b''))
# End if there's no more content
if not message.get("more_content", False):
self.finish()