run-dev: Don’t rewrite the Content-Length header.

A HEAD response has a Content-Length but no body; it’s not correct in
that case to let Tornado default Content-Length to 0.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-08-11 20:25:32 -07:00 committed by Tim Abbott
parent d425ab5ae5
commit ead13c11e5
1 changed files with 2 additions and 5 deletions

View File

@ -302,12 +302,9 @@ class CombineHandler(BaseWebsocketHandler):
self._headers = httputil.HTTPHeaders() # clear tornado default header
for header, v in response.headers.get_all():
if header != 'Content-Length':
# some header appear multiple times, eg 'Set-Cookie'
self.add_header(header, v)
# some header appear multiple times, eg 'Set-Cookie'
self.add_header(header, v)
if response.body:
# rewrite Content-Length Header by the response
self.set_header('Content-Length', len(response.body))
self.write(response.body)
self.finish()