diff --git a/CHANGES.md b/CHANGES.md index 2b13657a0..051ab1cc4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -23,6 +23,8 @@ * Missing response header "content-encoding" #421 +* Fix stream draining for http/2 connections #290 + ## [0.7.1] - 2018-07-21 diff --git a/src/pipeline.rs b/src/pipeline.rs index dbe9e58ad..7c277a587 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -409,7 +409,7 @@ struct ProcessResponse { _h: PhantomData, } -#[derive(PartialEq)] +#[derive(PartialEq, Debug)] enum RunningState { Running, Paused, diff --git a/src/server/h2.rs b/src/server/h2.rs index 2322f755a..e5355a1fd 100644 --- a/src/server/h2.rs +++ b/src/server/h2.rs @@ -155,7 +155,9 @@ where } } - if !item.flags.contains(EntryFlags::WRITE_DONE) { + if item.flags.contains(EntryFlags::FINISHED) + && !item.flags.contains(EntryFlags::WRITE_DONE) + { match item.stream.poll_completed(false) { Ok(Async::NotReady) => (), Ok(Async::Ready(_)) => { diff --git a/src/server/h2writer.rs b/src/server/h2writer.rs index c877250dd..ff87b693e 100644 --- a/src/server/h2writer.rs +++ b/src/server/h2writer.rs @@ -245,14 +245,18 @@ impl Writer for H2Writer { let cap = cmp::min(self.buffer.len(), CHUNK_SIZE); stream.reserve_capacity(cap); } else { + if eof { + stream.reserve_capacity(0); + continue; + } self.flags.remove(Flags::RESERVED); - return Ok(Async::NotReady); + return Ok(Async::Ready(())); } } Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)), } } } - Ok(Async::NotReady) + Ok(Async::Ready(())) } }