From 051703eb2c721d3a44f210ff29a784dfc6ecca9d Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 11 Mar 2018 15:37:33 -0700 Subject: [PATCH] Fix connection get closed too early --- CHANGES.md | 2 ++ src/server/h1.rs | 21 +++++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) 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