twisted / twisted/twisted

twisted.web.resource.Resource.allowedMethods doesn't determine what methods are allowed

Open
#4,958 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug new priority-normal web
Dominant language
Python
Stars
6k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
10

Description

washort's avatar @washort reported
Trac ID trac#4958
Type defect
Created 2011-03-15 19:20:44Z

Resource.render only consults allowedMethods after looking for a render_ method. If a render_FOO method exists, it's invoked; allowedMethods is only used to populate the Allow header in the response.

To quote wsanchez from #3684:

OK, so with this API, if you have `allowedMethods = ["GET"]`, then even though you are telling us that you don't want to allow HEAD (for whatever reason), we're going to ignore you and allow it anyway.

This strikes me as strangely inconsistent/exceptional API, so that bothers me. What I would prefer is that if you say allowedMethods = ["GET", "HEAD"], but you don't implement the HEAD method, then we'll use your GET implementation to provide HEAD.

That is, we should do what you ask us to do, and not pretend that we know better.

Searchable metadata
trac-id__4958 4958
type__defect defect
reporter__washort washort
priority__normal normal
milestone__ 
branch__ 
branch_author__ 
status__new new
resolution__None None
component__web web
keywords__ 
time__1300216844000000 1300216844000000
changetime__1300493988000000 1300493988000000
version__None None
owner__ 
cc__jknight

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 at twisted.web.resource.Resource.render, where the issue says allowedMethods is checked after render_ lookup. Trace how GET, HEAD, and other render methods are dispatched, then add coverage showing that allowedMethods controls which methods are accepted and that the Allow header matches the permitted methods.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.