rw-stream-sink: Skip over empty stream items.
Otherwise it may report the reading of 0 bytes which is interpreted as
EOF by consumers of `std::io::Read::read`.
@@ -80,8 +80,16 @@ where
};
if need_new_item {
+ loop {
self.current_item = match self.inner.poll() {
- Ok(Async::Ready(i)) => i.map(|b| b.into_buf()),
+ Ok(Async::Ready(None)) => None,
+ Ok(Async::Ready(Some(i))) => {
+ let b = i.into_buf();
+ if !b.has_remaining() {
+ continue // skip over empty items
+ }
+ Some(b)
+ }
Ok(Async::NotReady) => {
if written == 0 {
return Err(IoError::new(IoErrorKind::WouldBlock, "stream not ready"));
@@ -97,6 +105,8 @@ where
}
}
};
+ break
+ }
}
let current_item = match self.current_item {
