diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs index 76a9c3e20c..fb0ce04d8a 100644 --- a/src/client/dispatch.rs +++ b/src/client/dispatch.rs @@ -197,13 +197,11 @@ impl Receiver { } } - #[cfg(feature = "http1")] pub(crate) fn close(&mut self) { self.taker.cancel(); self.inner.close(); } - #[cfg(feature = "http1")] pub(crate) fn poll_close(&mut self, cx: &mut Context<'_>) -> Poll<()> { self.close(); // A send that started before close may still be publishing its envelope. diff --git a/src/proto/h2/client.rs b/src/proto/h2/client.rs index eb768baa76..6f46f74931 100644 --- a/src/proto/h2/client.rs +++ b/src/proto/h2/client.rs @@ -201,6 +201,7 @@ where h2_tx, req_rx, fut_ctx: None, + closing: None, marker: PhantomData, }) } @@ -434,6 +435,7 @@ where h2_tx: SendRequest>, req_rx: ClientRx, fut_ctx: Option>, + closing: Option>, marker: PhantomData, } @@ -676,6 +678,24 @@ where type Output = crate::Result; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + if self.closing.is_none() { + let res = ready!(self.poll_dispatch(cx)); + self.closing = Some(res); + } + ready!(self.req_rx.poll_close(cx)); + Poll::Ready(self.closing.take().expect("Future polled twice")) + } +} + +impl ClientTask +where + B: Body + 'static + Unpin, + B::Data: Send, + B::Error: Into>, + E: Http2ClientConnExec + Clone + Unpin, + T: Read + Write + Unpin, +{ + fn poll_dispatch(&mut self, cx: &mut Context<'_>) -> Poll> { loop { match ready!(self.h2_tx.poll_ready(cx)) { Ok(()) => (),