Skip to content

Treat the HTTP/2 Expect field value as a list of expectations - #1265

Open
arturobernalg wants to merge 2 commits into
apache:mainfrom
arturobernalg:http2-expect-list
Open

arturobernalg wants to merge 2 commits into
apache:mainfrom
arturobernalg:http2-expect-list

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

This builds on #1263, which is its first commit. Only the second commit is new; I will rebase once #1263 is merged.

RFC 9110, section 10.1.1 defines Expect as a list (Expect = #expectation). An origin server that receives a request whose header section "contains a 100-continue expectation and an indication that request content will follow" MUST send either an immediate final response or an immediate 100 (Continue) response. Over HTTP/2, a request with Expect: foo, 100-continue got neither and the server waited for the request content.

With curl, a 200 KB POST and an 8 second expect timeout:

Expect main, HTTP/2 main, HTTP/1.1 httpd 2.4.69 mod_http2 this PR, HTTP/2
100-continue, foo 200 after 8 s, no 100 417 at once 417 at once 200 in a few ms
foo, 100-continue 200 after 8 s, no 100 417 at once 417 at once 200 in a few ms
100-continue,100-continue 200 after 8 s, no 100 417 at once 417 at once 200 in a few ms

The value is now parsed with TokenList.parseTokenList(), the list parser already used for Connection and Transfer-Encoding, after a fast path for a single 100-continue. Other expectations are ignored: the 417 response is only a MAY and HTTP/2 already ignored Expect: foo. HTTP/1.1 is not changed.

testSendAckList and testSendAckListWithEmptyElements in TestHttp2Section_8_1 fail without the change; testNoAckForOtherExpectation and testNoAckForContinueWithParameter check that no 100 (Continue) response is sent for foo or 100-continue=1.

Known limitation: TokenList does not handle quoted strings, so an expectation such as foo="a, 100-continue, b" also gets a 100 (Continue) response. That is harmless, as RFC 9110, section 15.2 says "A client MUST be able to parse one or more 1xx responses received prior to a final response, even if the client does not expect one."

RFC 9110, section 10.1.1 defines the Expect field value as
case-insensitive. HTTP/1.1 already compares 100-continue ignoring case
but HTTP/2 did not, so no 100 (Continue) response was sent for a request
with "Expect: 100-Continue".
RFC 9110, section 10.1.1 defines Expect as a list. A request with
"Expect: foo, 100-continue" over HTTP/2 got neither a 100 (Continue)
response nor an immediate final response, so the server waited for the
request content.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant