Repository navigation
Conversation
Per RFC 9110, 10.1.1: If a request has `Expect: 100-continue`, the server should either send `100 Continue` to say it is ready for the request body, or send a final status such as `417 Expectation Failed`. The HTTP/1 server handles this correctly: it sends `100 Continue` the first time the service polls the request body. However, the HTTP/2 server ignores `Expect`, so a client that waits for `100 Continue` before sending its body stalls until its own timeout. Fix this by making the HTTP/2 server send `100 Continue` after the service first polls the request body. Note that if the body has already started arriving by then, this means the client did not wait, so we skip the `100 Continue` (which RFC 9110 allows). As with HTTP/1, nothing is sent if the request has no body, or if the service responds before polling the body, since an interim response cannot follow the final response. Fixes hyperium#2743 Refs: hyperium#2119, hyperium#3137
fe9f289 to
6d363f7
Compare
|
We urgently need this feature to be merged and a new version released. Thank you all! |
BTF-Kabir-2020
left a comment
There was a problem hiding this comment.
I went through this against the old #2743 discussion and the HTTP/1 path (#2119 and #3137). Wiring the h2 side to the same "wait until the service polls the body" rule looks like the right approach. RFC 9113 §8.8.5 explicitly shows 100 Continue as an HTTP/2 HEADERS frame with :status = 100, and the pinned h2 (0.4.14) already has SendResponse::send_informational, so no dependency bump is needed.
Two things I'd like to clarify before this lands:
-
src/body/incoming.rs— theres.is_pending()condition.A
Ready(Ok(Some(_)))from the firstpoll_framesuppresses the 100 even if that frame was only the first DATA frame of a larger body. RFC 9110 §10.1.1 explicitly allows omitting 100 Continue if the server has already received "some or all" of the content, so I agree with the current behaviour. However, the comment currently says only "the body hasn't already arrived", which could be read as referring to the whole body. A short reference to that RFC clause would make the intent clearer. -
tests/server.rs—h2_expect_continue_but_body_already_sent_is_ignored.This test looks scheduler-dependent.
send_data()queues the DATA frame on the client stream, but doesn't guarantee the server has it before the service's first body poll. If the server's first body poll happens before the DATA frame has been received, the oneshot fires and the server quite correctly sends a 100, soh2_assert_no_informationalfails even though the implementation is fine.Could we make the DATA arrival deterministic rather than relying on task ordering? I'd avoid fixing this by only moving the assertion later:
poll_informationalreturnsReady(None)once no more informational responses are expected, so polling after the final response is queued could hide a 100 that really was sent (https://docs.rs/h2/0.4.14/h2/client/struct.ResponseFuture.html#method.poll_informational).
Other than that, the implementation looks consistent with the existing HTTP/1 behaviour and the feature gates line up. I haven't run the suite locally — this is from reading the diff, the protocol text, and the pinned h2 API.
Happy to take another look once the test ordering is settled.
Per RFC 9110, 10.1.1: If a request has
Expect: 100-continue, the server should either send100 Continueto say it is ready for the request body, or send a final status such as417 Expectation Failed.The HTTP/1 server handles this correctly: it sends
100 Continuethe first time the service polls the request body. However, the HTTP/2 server ignoresExpect, so a client that waits for100 Continuebefore sending its body stalls until its own timeout.Fix this by making the HTTP/2 server send
100 Continueafter the service first polls the request body. Note that if the body has already started arriving by then, this means the client did not wait, so we skip the100 Continue(which RFC 9110 allows). As with HTTP/1, nothing is sent if the request has no body, or if the service responds before polling the body, since an interim response cannot follow the final response.Fixes #2743
Refs: #2119, #3137