tornadoweb / tornadoweb/tornado

HTTP 405 response must include an Allow header

Open
#902 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

web
Dominant language
Python
Stars
22.2k
Forks
5.6k
Avg merge
3h 42m
Merged PRs (30d)
16

Description

When an HTTPError(405) is raised, either manually or automatically because of not implementing a handler, Tornado does not set the officially required Allow header. Worse, if I set it myself, it is erased by RequestHandler.send_error. Bluntly said, it means that Tornado does not follow HTTP standards.

When addressing this, please consider adding a possibility to override the list of supported methods, rather than looking only at the present handlers; I built my own mechanism to limit their usage at certain URLs:

class BaseHandler(RequestHandler):
    def initialize(self, *args, **kwargs):
        self.allowed_methods = kwargs.get('allowed_methods', type(self).SUPPORTED_METHODS)

    def prepare(self):
        if self.request.method not in self.allowed_methods: raise HTTPError(405)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing HTTPError(405) through RequestHandler.send_error and the automatic path for requests without a handler. Check how the Allow header is currently generated or cleared, including the issue's proposed allowed_methods override. Done means a 405 response preserves or sets an Allow header that reflects the supported methods, including custom restrictions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.