tornadoweb / tornadoweb/tornado
Send 204 as HTTPError
Open
Nobody has claimed this yet.
web
- Dominant language
- Python
- Stars
- 22.2k
- Forks
- 5.6k
- Avg merge
- 3h 42m
- Merged PRs (30d)
- 16
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading Tornado's HTTPError handling and the send_error and finish entry points mentioned in the traceback. Reproduce the issue with HTTPError(204), including under python -O, and inspect the response buffer and no-content assertion. Done means a 204 response can be sent without a body or assertion failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100