Skip to content

Send 204 as HTTPError #3360

Open
Open
@pawciobiel

Description

@pawciobiel

Occasionally it is useful to send HTTP204 via exception raise HTTPError(204) .
Also when run with python -O assertions are removed causing the check for no content useless.
But the response buffer has value:

[b'<html><title>204: No Content</title><body>204: No Content</body></html>']
Traceback (most recent call last):
  File "/home/pgb/.local/lib/python3.10/site-packages/tornado/web.py", line 1791, in _execute
    self._handle_request_exception(e)
  File "/home/pgb/.local/lib/python3.10/site-packages/tornado/web.py", line 1846, in _handle_request_exception
    self.send_error(e.status_code, exc_info=sys.exc_info())
  File "/home/pgb/.local/lib/python3.10/site-packages/tornado/web.py", line 1298, in send_error
    self.finish()
  File "/home/pgb/.local/lib/python3.10/site-packages/tornado/web.py", line 1219, in finish
    assert not self._write_buffer, (
AssertionError: Cannot send body with 204

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions