Add into_inner() for HTTP client and server
This adds the into_inner() function to the stream type, allowing the HTTP/1.1 client and server to be turned back into a stream.
These functions are useful for implementing HTTP CONNECT or HTTP Upgrade.
This addresses https://github.com/cloudflare/pingora/issues/230
I do not think the failure is related.
I feel like this is a common-ish rust pattern, where you have into_inner(), that then returns the original thing the object was built from. We'd probably want to flush, but I think a reasonable way to make the API is something like:
At least for the HTTP v1 client:
pub async fn into_inner(self) -> Result<Stream> {
self.underlying_stream
.flush()
.await
.or_err(WriteError, "flushing body")?;
Ok(self.underlying_stream)
}
The other option, which extends our current story is:
fn stream_mut(&mut self) -> &mut Stream {
&mut self.underlying_stream
}
Curious, what folks find more palatable?
Bump?
Thank you for your contribution! this was merged in 63af8e28f24e36db7d4c092a1edbe5dca80d0a23.