-
Notifications
You must be signed in to change notification settings - Fork 44
Improve Expect: 100-continue
header handling
#135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This makes sense. Do you think that this is a situation where applications might want to change the default behavior? Some apps might want to check that the request is valid before receiving the body, and some might prefer not to take the small performance hit and always immediately begin receiving the body I'm going to make a try at this because it sounds interesting, but it seems very likely to conflict with @Yarn's #134, which isn't ready to merge and touches a lot of files |
Tiny bit of spec-lawyering: I'm not convinced that the word "correct" in the title is accurate. I think the type of validation proposed here is optional origin server behavior. Here's the relevant part of rfc2616§8:
and the relevant part of RFC 7231§5.1.1:
Nowhere does it require that the origin server do anything special to validate the headers. |
Expect: 100-continue
header handlingExpect: 100-continue
header handling
Ah, I was envisioning this would just work™. If sending the Re: the spec -- I've updated the title. You're right that we're currently spec-compliant, but we could be doing better. |
tldr: We're currently always accepting
Expect: 100-continue
headers, where we should be enabling header validation before we send back an intermediate100
status code.Expected behavior
The
100 continue
header exists in order to signal to a client that the request has been understood, and all the headers are correct. This enables validating things like encoding, offsets, and authentication before proceeding to transfer a significant amount of data.The validation of these headers should be defined by end-users, as they are the ones that will know which combination of headers is acceptable.
Current behavior
async-h1
is currently hardcoded to always reply with100
to theExpect: 100-continue
header. This means end-users don't have a chance to validate headers before proceeding.async-h1/src/server/decode.rs
Lines 132 to 144 in 3a368bd
Implementation
We should provide some way for end-users to validate headers before sending back the 100 continue response. I'm not quite sure how to do this, but one option would be to handle only send over
100-continue
when the first chunk of the request body is requested. That would indicate that the framework has successfully parsed the headers, and is now ready to receive the body.If a
Response
is returned before theRequest
body has finished, that would likely carry anon-100
status code, and the client would know not to send the request body. So semantically I think that would be the right way to go?If at all possible I think we should evade exposing the
Expect: 100-continue
semantics to end-users, since the back and forth dance is quite complex, needs to work out of the box, and doesn't fit well with thereq/res
model we use in http-rs.The text was updated successfully, but these errors were encountered: