Response parser requires support for HEAD responses without body
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start at HttpResponseParser.feed_data(self, data: bytes) and trace how response boundaries and body expectations are handled for pipelined responses. The work is done when HEAD responses can be parsed without bodies, including Content-Length headers, while pipelined HEAD and GET responses remain correctly separated.
Written by the indexing model from the issue text.
Description
According to the specification of HTTP/1.1 ...
Responses to the HEAD request method never include a message body because the associated response header fields (e.g., Transfer-Encoding, Content-Length, etc.), if present, indicate only what their values would have been if the request method had been GET.
Source: RFC 7230 (Section 3.3)
... responses to HEAD requests do not have a body. Even if e.g. the Content-Length header is present.
However, the response parser cannot know based on the data it receives whether the corresponding request was using the HEAD or another method and whether to expect a body or to just ignore any header flags about the content.
Suggestion:
Add an additional boolean flag to HttpResponseParser.feed_data(self, data: bytes) to tell the parser that it should not expect a body (or even throw a parser exception if there is one present).
Because HTTP/1.1 also allows pipelining, this additional parameter should also rather be a list of "body presence" flags. Here's why:
If you send multiple requests to a server without waiting for the responses (= pipelining), you are going to receive back a bunch of responses together. Without them being parsed yet, one cannot identify the message boundaries and therefore they cannot be fed to the parser one by one. So the parser has to support that the whole stack of responses is fed to it and it needs a list of the "expected body presence".
Example:
If the pipelined requests were something like {HEAD, GET, HEAD, GET}, the "body presence" flags need to alternate as well.
For convenience, it may be good to have a parameter that can be set using both types, a single flag and a list of flags.
- Dominant language
- Python
- Stars
- 1.3k
- Forks
- 107
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
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.
More from MagicStack/httptools
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MagicStack/httptools#136 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
MagicStack/httptools#140 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
MagicStack/httptools#127 · 2 comments · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
MagicStack/httptools#126 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
MagicStack/httptools#125 ·
All issues in MagicStack/httptools
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
learningequality/ricecooker#747 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
run-llama/llama_index#23199 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
KhronosGroup/glTF-Blender-IO#2769 ·