Skip to content

Commit

Permalink
Only call _clear_headers_for_304 on 304 responses
Browse files Browse the repository at this point in the history
Fixes #2726.

Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Aug 12, 2019
1 parent 8e5ecad commit 7119179
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tornado/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -1138,10 +1138,11 @@ def finish(self, chunk: Optional[Union[str, bytes, dict]] = None) -> "Future[Non
assert not self._write_buffer, (
"Cannot send body with %s" % self._status_code
)
self._clear_headers_for_304()
elif "Content-Length" not in self._headers:
content_length = sum(len(part) for part in self._write_buffer)
self.set_header("Content-Length", content_length)
if self._status_code == 304:
self._clear_headers_for_304()

assert self.request.connection is not None
# Now that the request is finished, clear the callback we
Expand Down

0 comments on commit 7119179

Please sign in to comment.