This Month in hyper: July 2022
I’d like to start providing more frequent updates of all the work that’s done in hyper, along with examples, details, and thanks. As a bonus, I included things from June in here as well.
Release v0.14.20
While we will release often when there’s new bug fixes grouped up, this release has a helpful new feature for people who write proxies and gateways.
hyper::ext::ReasonPhrase
One of the new features in v0.14.20 is the ability to interact more with the HTTP/1 reason-phrase of an HTTP response. This is a sort-of deprecated part of HTTP (the reason-phrase does not exist in HTTP/2 or 3), but sometimes important information is still put in them. The http::StatusCode
type does not include a String
field for the reason-phrase, because of that deprecation, and to decrease the memory size of the type.
Consider this response with a custom reason-phrase:
HTTP/1.1 200 Stupendous
If you do need to access it, now you can! If the client receives a response with a non-standard phrase, it will be saved in the response extensions. So, a client would do so like this:
use hyper::ext::ReasonPhrase;
let resp = client.get(url).await?;
if let Some(phrase) = resp.extensions().get::<ReasonPhrase>() {
eprintln!("got {} {:?}", resp.status(), phrase);
}
And a server can send a custom phrase by including the extension, like so:
use hyper::ext::ReasonPhrase;
async fn handle(_req: Request) -> Result<Response, Infallible> {
let mut resp = Response::new(Body::empty());
// There's also TryFrom impls for non-static values.
let phrase = ReasonPhrase::from_static("Stupendous");
resp.extensions_mut().insert(phrase);
Ok(resp)
}
Thanks a bunch to Adam Foltzer for the work on this feature!
hyper 1.0 started
Development work on 1.0 started in June. Progress can be tracked in the public dashboard. Some major work done so far includes splitting the client connection type per HTTP version, for forwards compatibility, and moving the connection pool implementation and the Tokio connect
integration to hyper-util
. Thanks to @oddgrd, @tomarkw, @dswij!
There’s several more big PRs nearing completion too, looking forward to thanking them next month.
hyper in curl
In June, we fixed the way curl would pause and resume request bodies when using hyper, resulting in 4 more of the remaining unit tests to pass. In July, a brand new contributor (thanks @deantvv!) add the FFI function to use hyper’s existing obs-folded headers support. A PR just merged aligns how curl expects obs-folded headers and how hyper treats them, which should fix another couple unit tests.
There’s a dashboard if you’d like to help this momentous work.
HTTP/3
The HTTP/3 specification was published as RFC 9114. I gave a small recap of the state of HTTP/3 in hyper.
In the same time period, hyper’s HTTP/3 library saw some increased development, from three brand new contributors, two of which have made over 3 contributions each. The work includes making request streams splittable into a send and receive side, and support for “GREASE” streams and frames. Thank you @Ruben2424, @yu-re-ka, and @inflation!
I’ve started some work on a tower-h3
crate, which would make it easier to plug HTTP/3 into an existing Tower codebase. I really do need to push this stuff to GitHub.
I also wrote up an issue to add experimental support to reqwest
. Getting it into reqwest would mean users could start trying it out more easily, and we could learn how to adjust the h3
crate API before making it part of hyper
directly. It would likely be easier to do this if the tower-h3
crate were ready, as an intermediate step. Volunteers welcome!