Skip to content
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

Support SendResponse::send_continue #601

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rawler
Copy link

@rawler rawler commented Feb 4, 2022

Support for Expect: 100-continue is mandated as MUST by
https://datatracker.ietf.org/doc/html/rfc7231#section-5.1.1. Yet servers
built on h2 cannot currently support this requirement.

One example of such usage, is hyper #2743.

This approach adds a send_continue method to SendResponse that a server
application can use to implement support itself. This PR does not solve
the feature itself, it merely provides sufficient support for a server
application to implement the functionality as desired.

@rawler
Copy link
Author

rawler commented Feb 4, 2022

One possible alternate solution, could be to implement more of the functionality directly, by hooking up the first attempt to read the request-body, as a signal to send 100-continue, if the header was there on the Request. Ideally, that would be implemented in Request::into_body, or add the behavior to the first call of RecvStream::poll_data. However, it seemed more invasive than I'd like it to be, and I didn't manage to wire it up in an acceptable way anyways.

src/proto/streams/state.rs Show resolved Hide resolved
src/server.rs Outdated
/// [`SendResponse`]: #
/// [`send_reset`]: #method.send_reset
/// [`send_response`]: #method.send_response
pub fn send_continue(&mut self) -> Result<(), crate::Error> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be out-of-scope to suggest this, but should we perhaps consider a slightly broader method, that allows sending other informational responses, like 103 Early Hints or future codes? In that case, we'd want to be able to send headers too...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it when writing the PR, but avoided it since I'm not sure what it's signature should be. send_info(Response<()>) feels a bit too wide, given that practically only 1xx responses are allowed here. OTOH, send_response(Response<()>) is also wider than it technically supports. (Extensions are cleared, the body unused, and the only Version supported really, is HTTP2), so maybe such API is fine.

src/proto/streams/state.rs Show resolved Hide resolved
@rawler
Copy link
Author

rawler commented Feb 6, 2022

Thank you 🙏 for a good and clear review. I've changed the according to the feedback.

@rawler
Copy link
Author

rawler commented Feb 25, 2022

Ping

@rawler rawler requested a review from seanmonstar March 8, 2022 12:58
@rawler
Copy link
Author

rawler commented May 2, 2022

Ping

@rawler
Copy link
Author

rawler commented Dec 12, 2022

Ping @seanmonstar

@rawler
Copy link
Author

rawler commented Dec 13, 2022

Maybe @LucioFranco have some time for a review? 🙏

@zh-jq
Copy link

zh-jq commented Apr 4, 2023

Any progress? It's an important feature

@zh-jq-b
Copy link

zh-jq-b commented Jun 27, 2023

@seanmonstar This is ready for a new review, do you have anytime to do it?

@mspublic
Copy link

Any update on this @seanmonstar @LucioFranco ?

@GlenDC
Copy link
Contributor

GlenDC commented Oct 4, 2024

As discussed on discord, I'm willing to help out in any capacity that you can use me to get this PR shipped. Be it more code contribution, review, testing, docs, ... do let me know.

/// [`SendResponse`]: #
/// [`send_reset`]: #method.send_reset
/// [`send_response`]: #method.send_response
pub fn send_info(&mut self, response: Response<()>) -> Result<(), crate::Error> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this just needs to document with a # Panics section that passing a response with a non-1xx status code is a misuse of the method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and fixed.

Support for `Expect: 100-continue` is mandated as MUST by
https://datatracker.ietf.org/doc/html/rfc7231#section-5.1.1. Yet servers
built on `h2` cannot currently support this requirement.

One example of such usage, is [hyper #2743](hyperium/hyper#2743).

This approach adds a `send_info` method to `SendResponse` that a server
application can use to implement support itself. This PR does _not_ solve
the feature itself, it merely provides sufficient support for a server
application to implement the functionality as desired.
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.

6 participants