Skip to content

Commit

Permalink
feat(client): add http1::Connection without_shutdown() method (hy…
Browse files Browse the repository at this point in the history
…perium#3430)

Signed-off-by: Sven Pfennig <s.pfennig@reply.de>
  • Loading branch information
kiron1 authored and 0xE282B0 committed Jan 16, 2024
1 parent 34f7128 commit aa696c2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/client/conn/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ where
pub fn poll_without_shutdown(&mut self, cx: &mut Context<'_>) -> Poll<crate::Result<()>> {
self.inner.poll_without_shutdown(cx)
}

/// Prevent shutdown of the underlying IO object at the end of service the request,
/// instead run `into_parts`. This is a convenience wrapper over `poll_without_shutdown`.
pub async fn without_shutdown(self) -> crate::Result<Parts<T>> {
let mut conn = Some(self);
futures_util::future::poll_fn(move |cx| -> Poll<crate::Result<Parts<T>>> {
ready!(conn.as_mut().unwrap().poll_without_shutdown(cx))?;
Poll::Ready(Ok(conn.take().unwrap().into_parts()))
})
.await
}
}

/// A builder to configure an HTTP connection.
Expand Down

0 comments on commit aa696c2

Please sign in to comment.