HTTPChannel should ignore Content-Length when Transfer-Encoding=chunked
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 10
Description
| enolte reported | |
|---|---|
| Trac ID | trac#6148 |
| Type | defect |
| Created | 2012-10-18 21:39:54Z |
RFC 2616 (http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4) says that the Content-Length header should be ignored when the Transfer-Encoding is chunked.
twisted.web.http.HTTPChannel.headerReceived() mistakenly sets _transferDecoder to _IdentityTransferDecoder and length to non-None whenever it receives a "Content-Length: ###" header after a "Transfer-Encoding: chunked" header.
This is causes the Request to receive the wrong body since it includes the chunk headers as well as the chunk data.
A possible solution is:
def headedReceived(self, line):
...
if header == 'content-length' and not isinstance(self._transferDecoder, _ChunkedTransferDecoder):
...
Another solution is to set self._transferDecoder in allHeadersReceived() where the method has access to all the headers.
Searchable metadata
trac-id__6148 6148
type__defect defect
reporter__enolte enolte
priority__normal normal
milestone__
branch__
branch_author__
status__new new
resolution__None None
component__web web
keywords__
time__1350596394000000 1350596394000000
changetime__1584359757768872 1584359757768872
version__None None
owner__
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 in twisted.web.http.HTTPChannel.headerReceived() and compare its handling of Content-Length after Transfer-Encoding: chunked with RFC 2616 section 4.4. Verify that a chunked request body is decoded without including chunk headers or using the Content-Length value; add or update the relevant HTTP tests if the surrounding test location is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100