Skip to content

Commit 1112957

Browse files
adds pub async fn ready to each of conn::{http1,http2}::SendRequest
1 parent 6b29780 commit 1112957

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/client/conn/http1.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ impl<B> SendRequest<B> {
137137
self.dispatch.poll_ready(cx)
138138
}
139139

140+
/// Waits until the dispatcher is ready
141+
///
142+
/// If the associated connection is closed, this returns an Error.
143+
pub async fn ready(&mut self) -> crate::Result<()> {
144+
futures_util::future::poll_fn(|cx| self.poll_ready(cx)).await
145+
}
146+
140147
/*
141148
pub(super) async fn when_ready(self) -> crate::Result<Self> {
142149
let mut me = Some(self);

src/client/conn/http2.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ impl<B> SendRequest<B> {
7474
}
7575
}
7676

77+
/// Waits until the dispatcher is ready
78+
///
79+
/// If the associated connection is closed, this returns an Error.
80+
pub async fn ready(&mut self) -> crate::Result<()> {
81+
futures_util::future::poll_fn(|cx| self.poll_ready(cx)).await
82+
}
83+
7784
/*
7885
pub(super) async fn when_ready(self) -> crate::Result<Self> {
7986
let mut me = Some(self);

src/client/conn/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141
//!
4242
//! // To send via the same connection again, it may not work as it may not be ready,
4343
//! // so we have to wait until the request_sender becomes ready.
44-
//! // TODO:(mike) how to handle readiness
45-
//! // request_sender.ready().await?;
44+
//! request_sender.ready().await?;
4645
//! let request = Request::builder()
4746
//! .header("Host", "example.com")
4847
//! .method("GET")

0 commit comments

Comments
 (0)