feat(http): add get_mut method to HttpReader

This commit is contained in:
Sean McArthur
2015-05-23 15:11:37 -07:00
parent e9dcf45df3
commit e64ce8c05e

View File

@@ -59,6 +59,16 @@ impl<R: Read> HttpReader<R> {
EmptyReader(r) => r,
}
}
/// Gets a mutable reference to the underlying Reader.
pub fn get_mut(&mut self) -> &mut R {
match *self {
SizedReader(ref mut r, _) => r,
ChunkedReader(ref mut r, _) => r,
EofReader(ref mut r) => r,
EmptyReader(ref mut r) => r,
}
}
}
impl<R> fmt::Debug for HttpReader<R> {
@@ -121,7 +131,9 @@ impl<R: Read> Read for HttpReader<R> {
Ok(count as usize)
},
EofReader(ref mut body) => {
body.read(buf)
let r = body.read(buf);
trace!("eofread: {:?}", r);
r
},
EmptyReader(_) => Ok(0)
}