Add HTTP/2 103 Early Hints Support to Hyper
Summary
This tracking issue covers the implementation of HTTP/2 103 Early Hints support across the hyper ecosystem. The work has been completed across three repositories with a phased merge strategy.
Implementation Overview
HTTP 103 Early Hints (RFC 8297) allows servers to send resource preloading hints while preparing the final response, enabling browsers to start downloading critical resources early for improved performance.
Completed Work
Repository Changes
HTTP Repository (http crate)
- Added
StatusCode::EARLY_HINTSconstant - Branch:
http-103
H2 Repository (HTTP/2 protocol layer)
- Implemented HTTP/2 informational responses (1xx) protocol support
- Added comprehensive unit tests
- Branch:
http-103
Hyper Repository (Application layer)
- Joel Dice's foundational work (PR #3815): Basic 1xx informational response support
- Extended implementation: Complete HTTP/2 103 Early Hints with client callbacks and server support
- Branch:
http-103
Implementation Details
Server-Side API
async fn handler(mut req: Request<Body>) -> Result<Response<Body>, Error> {
if let Some(mut sender) = req.extensions_mut().remove::<InformationalSender>() {
let hints = Response::builder()
.status(StatusCode::EARLY_HINTS)
.header("link", "</css/critical.css>; rel=preload; as=style")
.header("link", "</js/app.js>; rel=preload; as=script")
.body(())
.unwrap();
sender.try_send(hints)?;
}
Ok(Response::new("Final response"))
}
Client-Side API
let config = InformationalConfig::new().with_callback(|response| {
if response.status() == StatusCode::EARLY_HINTS {
for link in response.headers().get_all("link") {
start_preload(link);
}
}
});
let client = Client::builder().http2_only(true).build_with_config(config);
Benefits
- Improved page load performance through parallel resource loading
- RFC 8297 compliant implementation
- Backward compatible with existing applications
- Comprehensive test coverage
Pull Requests
Phase 1: Foundation Components (Ready Now)
- http crate PR: Add StatusCode::EARLY_HINTS constant - https://github.com/hyperium/http/pull/794
- h2 crate PR: HTTP/2 informational responses protocol support - https://github.com/hyperium/h2/pull/865
- Joel Dice's hyper PR #3815: Foundational 1xx informational responses - https://github.com/hyperium/hyper/pull/3815
Phase 2: Complete Implementation (After Phase 1 Merge)
- Apu Islam's hyper PR: Complete HTTP/2 103 Early Hints implementation - [Will be submitted after Phase 1 merges]
Merge Strategy
Phase 1: Foundation Components
- http crate: StatusCode::EARLY_HINTS constant
- h2 crate: HTTP/2 informational responses protocol support
- hyper: Joel Dice's foundational 1xx informational responses (PR #3815)
Phase 2: Complete Implementation
- hyper: Complete HTTP/2 103 Early Hints with client callbacks and production examples
Action Items
Phase 1 (Ready for Review)
- [ ] Review and merge http PR hyperium/http#794
- [ ] Review and merge h2 PR #865
- [ ] Review and merge hyper PR #3815
Phase 2 (After Phase 1 Merge)
- [ ] Submit comprehensive hyper PR
- [ ] Review complete implementation
- [ ] Verify production examples and documentation
References
- RFC 8297: https://datatracker.ietf.org/doc/html/rfc8297
- Original Request: https://github.com/hyperium/hyper/issues/2426
- Joel Dice's Foundation Work: https://github.com/hyperium/hyper/pull/3815
Status
Implementation complete across all three repositories. Phase 1 PRs ready for immediate review and merge. Phase 2 will follow after foundation is established.
- Must be merged first - http PR - https://github.com/hyperium/http/pull/794
- Should be merged next - h2 PR - https://github.com/hyperium/h2/pull/865
- Joel's PR - https://github.com/hyperium/hyper/pull/3815 should be merged either with mine or before, let me know what you think?
@seanmonstar @vikanezrimaya @dicej could you please review my PRs?
@apu031 I'm sorry, but the prose on this tracking issue description and your two PRs looks like unfiltered LLM output due to oververbosity and the emoji overload, and this makes it hard to read. Your second message with the list of links was much clearer and the overall tracking issue description should've probably been based on that with a much shorter cover letter-style issue description for the work performed.
Also, from a quick look at your PR's commit messages they don't seem to follow Hyper's contribution guidelines, in particular the commit guidelines which outline the format the commit messages should have.
I shall be checking out the code shortly.
@apu031 I'm sorry, but the prose on this tracking issue description and your two PRs looks like unfiltered LLM output due to oververbosity and the emoji overload, and this makes it hard to read. Your second message with the list of links was much clearer and the overall tracking issue description should've probably been based on that with a much shorter cover letter-style issue description for the work performed.
Also, from a quick look at your PR's commit messages they don't seem to follow Hyper's contribution guidelines, in particular the commit guidelines which outline the format the commit messages should have.
I shall be checking out the code shortly.
Thanks @vikanezrimaya. I wanted it to correct my grammars and polish but added some emojis. I removed them for proper readability. I will double check the contribution and the commit guidelines once again.