Skip to content

Commit

Permalink
fix(client): don't close stream until EOF
Browse files Browse the repository at this point in the history
Closes #543
  • Loading branch information
seanmonstar committed May 23, 2015
1 parent e64ce8c commit a5e6174
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/client/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ impl Response {
debug!("version={:?}, status={:?}", head.version, status);
debug!("headers={:?}", headers);

if !http::should_keep_alive(head.version, &headers) {
try!(stream.get_mut().close(Shutdown::Write));
}

let body = if headers.has::<TransferEncoding>() {
match headers.get::<TransferEncoding>() {
Expand Down Expand Up @@ -97,7 +94,15 @@ impl Response {
impl Read for Response {
#[inline]
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.body.read(buf)
let count = try!(self.body.read(buf));

if count == 0 {
if !http::should_keep_alive(self.version, &self.headers) {
try!(self.body.get_mut().get_mut().close(Shutdown::Both));
}
}

Ok(count)
}
}

Expand Down

0 comments on commit a5e6174

Please sign in to comment.