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

prototype support for 1xx informational responses #3815

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dicej
Copy link

@dicej dicej commented Dec 18, 2024

This is a prototype intended to spur discussion about what support for 1xx informational responses should look like in a Hyper server. The good news is that it works great (for HTTP/1 only, so far). The bad news is it's kind of ugly. Here's what I did:

  • Add ext::InformationalSender, a type which wraps a futures_channel::mspc::Sender<Response<()>>. This may be added as an extension to an inbound Request by the Hyper server, and the application and/or middleware may use it to send one or more informational responses before sending the real one.

  • Add code to proto::h1::dispatch and friends to add such an extension to each inbound request and then poll the Receiver end along with the future representing the final response. If the app never sends any informational responses, then everything proceeds as normal. Otherwise, we send those responses as they become available until the final response is ready.

TODO items:

  • Also support informational responses in the HTTP/2 server.
  • Determine best way to handle when the app sends an informational response with a non-1xx status code. Currently we just silently ignore it.
  • Come up with a less hacky API?
  • Add test coverage.

This is a prototype intended to spur discussion about what support for 1xx
informational responses should look like in a Hyper server.  The good news is
that it works great (for HTTP/1 only, so far).  The bad news is it's kind of
ugly.  Here's what I did:

- Add `ext::InformationalSender`, a type which wraps a
  `futures_channel::mspc::Sender<Response<()>>`.  This may be added as an
  extension to an inbound `Request` by the Hyper server, and the application
  and/or middleware may use it to send one or more informational responses
  before sending the real one.

- Add code to `proto::h1::dispatch` and friends to add such an extension to each
  inbound request and then poll the `Receiver` end along with the future
  representing the final response.  If the app never sends any informational
  responses, then everything proceeds as normal.  Otherwise, we send those
  responses as they become available until the final response is ready.

TODO items:
- [ ] Also support informational responses in the HTTP/2 server.
- [ ] Determine best way to handle when the app sends an informational response
  with a non-1xx status code.  Currently we just silently ignore it.
- [ ] Come up with a less hacky API?
- [ ] Add test coverage.

Signed-off-by: Joel Dice <[email protected]>
@dicej dicej marked this pull request as draft December 18, 2024 16:52
@seanmonstar seanmonstar added the A-server Area: server. label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-server Area: server.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants