Skip to content

Include Allow header in 405 responses - #3855

Merged
bdarnell merged 1 commit into
tornadoweb:masterfrom
DresdenGman:fix-902-allow-header
Nov 18, 2026
Merged

bdarnell merged 1 commit into
tornadoweb:masterfrom
DresdenGman:fix-902-allow-header

Conversation

@DresdenGman

Copy link
Copy Markdown
Contributor

Fixes #902.

A 405 response must carry an Allow header listing the methods the resource supports (RFC 9110, section 15.5.6), but tornado's 405 responses had no Allow header at all — neither the ones from the unimplemented-method stub nor the ones from the unknown-method check in _execute.

Every 405 path converges on RequestHandler.send_error, which also clears any preset headers first, so that is where the header is now built: when the status code is 405, a small helper compares each entry of SUPPORTED_METHODS against the base-class stub to find the methods the handler actually implements, and sets Allow accordingly.

Tests: full suite 1540 tests passing against a baseline of 1535, no new failures (112 environment skips on both sides). The new tests cover the Allow value for a GET-only handler across several unsupported methods, that non-405 errors carry no Allow header, and that a handler implementing more methods lists them all.

RFC 9110 section 15.5.6 requires a 405 response to include an
Allow header listing the methods supported by the target resource.
RequestHandler.send_error now sets the header for 405 responses
based on the methods the handler subclass actually implements.

Fixes tornadoweb#902
@bdarnell

Copy link
Copy Markdown
Member

Thanks.

@bdarnell
bdarnell merged commit 5466398 into tornadoweb:master Nov 18, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP 405 response must include an Allow header

2 participants