diff --git a/CHANGES.md b/CHANGES.md index f115cc03f..24f01b75c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,8 @@ * Fix panic on unknown content encoding +* Fix connection get closed too early + ## 0.4.6 (2018-03-10) * Fix client cookie handling diff --git a/src/server/h1.rs b/src/server/h1.rs index 097804ba2..e5cb04699 100644 --- a/src/server/h1.rs +++ b/src/server/h1.rs @@ -110,18 +110,6 @@ impl Http1 } } - fn poll_completed(&mut self, shutdown: bool) -> Result { - // check stream state - match self.stream.poll_completed(shutdown) { - Ok(Async::Ready(_)) => Ok(true), - Ok(Async::NotReady) => Ok(false), - Err(err) => { - debug!("Error sending data: {}", err); - Err(()) - } - } - } - // TODO: refactor pub fn poll_io(&mut self) -> Poll { // read incoming data @@ -272,8 +260,13 @@ impl Http1 } // check stream state - if !self.poll_completed(true)? { - return Ok(Async::NotReady) + match self.stream.poll_completed(self.tasks.is_empty()) { + Ok(Async::NotReady) => return Ok(Async::NotReady), + Err(err) => { + debug!("Error sending data: {}", err); + return Err(()) + } + _ => (), } // deal with keep-alive