HTTP/2 103 Early Hints Support by apu031 · Pull Request #3991 · hyperium/hyper

@apu031 mentioned this pull request

Dec 10, 2025

@dicej

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 <joel.dice@fermyon.com>

JakubKoralewski

Add HTTP/2 103 Early Hints implementation with client and server support:

- Add builder opt-in pattern via enable_informational() for zero-cost abstraction
- Create early_hints_pusher() API for server-side hint transmission via mpsc channel
- Add InformationalCallback system for client-side informational response handling
- Extend HTTP/2 client builder with informational_responses() configuration method
- Implement informational response polling in h2 client task with callback invocation
- Add server-side informational response forwarding using h2's send_informational API
- Include test coverage: 11 integration tests, 18 unit tests, 2 doc tests
- Add complete working example with TLS, resource preloading, and performance monitoring
- Update Cargo.toml with h2 = 0.4.13 dependency requirement

The implementation enables servers to send resource preload hints before final responses,
allowing browsers to start downloading critical resources early and improve page load
performance. Feature is opt-in and disabled by default for zero overhead when not used.
Clients can register callbacks to process 103 Early Hints and other informational responses.

Closes hyperium#3980, hyperium#2426