From 6fe3d6a8a03ed804cefdc06d6245bb579752f134 Mon Sep 17 00:00:00 2001 From: quininer Date: Fri, 26 Apr 2019 00:46:39 +0800 Subject: [PATCH] fix gzip + chunked encoding reuse of connection (#509) Closes #508 --- src/async_impl/decoder.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/async_impl/decoder.rs b/src/async_impl/decoder.rs index c909536..084863d 100644 --- a/src/async_impl/decoder.rs +++ b/src/async_impl/decoder.rs @@ -223,8 +223,11 @@ impl Stream for Gzip { }; match read { - Ok(read) if read == 0 => { - Ok(Async::Ready(None)) + Ok(read) if read == 0 => match self.inner.get_mut().read(&mut [0]) { + Ok(0) => Ok(Async::Ready(None)), + Ok(_) => Err(error::from(io::Error::new(io::ErrorKind::InvalidData, "Unexpected Data"))), + Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => Ok(Async::NotReady), + Err(e) => Err(error::from(e)) }, Ok(read) => { unsafe { self.buf.advance_mut(read) };