Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix end-of-stream handling in parse_payload #173

Merged
merged 1 commit into from
Apr 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/client/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,11 @@ impl HttpResponseParser {
if self.decoder.is_some() {
loop {
// read payload
let not_ready = match utils::read_from_io(io, buf) {
Ok(Async::Ready(0)) => {
if buf.is_empty() {
return Err(PayloadError::Incomplete)
}
true
}
let (not_ready, stream_finished) = match utils::read_from_io(io, buf) {
Ok(Async::Ready(0)) => (false, true),
Err(err) => return Err(err.into()),
Ok(Async::NotReady) => true,
_ => false,
Ok(Async::NotReady) => (true, false),
_ => (false, false),
};

match self.decoder.as_mut().unwrap().decode(buf) {
Expand All @@ -104,6 +99,9 @@ impl HttpResponseParser {
if not_ready {
return Ok(Async::NotReady)
}
if stream_finished {
return Err(PayloadError::Incomplete)
}
}
Err(err) => return Err(err.into()),
}
Expand Down