From c8713d045cf5969df0daa3c81b14b272a4492fc6 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Mon, 18 Feb 2019 21:41:38 -0800 Subject: [PATCH] poll payload again if framed object get flushed during same iteration --- src/h1/dispatcher.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/h1/dispatcher.rs b/src/h1/dispatcher.rs index 22d7ea86..9ae8cd2a 100644 --- a/src/h1/dispatcher.rs +++ b/src/h1/dispatcher.rs @@ -167,7 +167,7 @@ where } /// Flush stream - fn poll_flush(&mut self) -> Poll<(), DispatchError> { + fn poll_flush(&mut self) -> Poll> { if !self.framed.is_write_buf_empty() { match self.framed.poll_complete() { Ok(Async::NotReady) => Ok(Async::NotReady), @@ -180,11 +180,11 @@ where if self.payload.is_some() && self.state.is_empty() { return Err(DispatchError::PayloadIsNotConsumed); } - Ok(Async::Ready(())) + Ok(Async::Ready(true)) } } } else { - Ok(Async::Ready(())) + Ok(Async::Ready(false)) } } @@ -482,8 +482,12 @@ where } else { inner.poll_keepalive()?; inner.poll_request()?; - inner.poll_response()?; - inner.poll_flush()?; + loop { + inner.poll_response()?; + if let Async::Ready(false) = inner.poll_flush()? { + break; + } + } if inner.flags.contains(Flags::DISCONNECTED) { return Ok(Async::Ready(H1ServiceResult::Disconnected));