twisted / twisted/twisted

twisted.web.http requestReceived should accept patch and put as well as post.

Open
#9,759 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

yombo's avatar @yombo reported
Trac ID trac#9759
Type enhancement
Created 2020-01-21 05:39:31Z

Issue

Twisted web http requestReceived method only processes data from "form-data" or "x-www-form-urlencoded" if the method is POST(rfc 2616). However, PATCH (rfc 5789) and PUT (rfc 2616) are valid methods for manipulating resources as well.

Reference

https://github.com/twisted/twisted/blob/118ebe1a1053a2fbf1e9a95f9b679716c7b00124/src/twisted/web/http.py#L896

Only accepts "POST" for trying to parse arguments. However, PATCH and PUT should also attempt to get arguments as well.

According to: https://restfulapi.net/http-methods/ (any many other references)

POST: New record

PATCH: Partial update of record

PUT: Update existing record

Possible fix

  1. Would you accept a PR that changes this line:

if self.method == b"POST" and ctype and clength:

To:

if self.method in (b"POST", b"PATCH", b"PUT") and ctype and clength:

Searchable metadata
trac-id__9759 9759
type__enhancement enhancement
reporter__yombo yombo
priority__normal normal
milestone__None None
branch__ 
branch_author__ 
status__new new
resolution__None None
component__web web
keywords__None None
time__1579585171188304 1579585171188304
changetime__1586941540576717 1586941540576717
version__None None
owner__None None

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 in src/twisted/web/http.py at the requestReceived method and review the existing form-data and x-www-form-urlencoded parsing condition. Check how PATCH and PUT requests are handled alongside POST, then verify that arguments are parsed for all three methods without changing other request behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, networking
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.