add streaming body to requests and responses #3

Merged
lx merged 64 commits from stream-body into main 2022-09-13 10:56:54 +00:00
Showing only changes of commit 9362d26890 - Show all commits

View file

@ -101,14 +101,16 @@ impl ByteStreamReader {
} }
} }
/// Tries to fill the internal read buffer from the underlying stream. /// Tries to fill the internal read buffer from the underlying stream if it is empty.
/// Calling this might be necessary to ensure that `.eos()` returns a correct /// Calling this might be necessary to ensure that `.eos()` returns a correct
/// result, otherwise the reader might not be aware that the underlying /// result, otherwise the reader might not be aware that the underlying
/// stream has nothing left to return. /// stream has nothing left to return.
pub async fn fill_buffer(&mut self) { pub async fn fill_buffer(&mut self) {
if self.buf.is_empty() {
let packet = self.stream.next().await; let packet = self.stream.next().await;
self.add_stream_next(packet); self.add_stream_next(packet);
} }
}
/// Clears the internal read buffer and returns its content /// Clears the internal read buffer and returns its content
pub fn take_buffer(&mut self) -> Bytes { pub fn take_buffer(&mut self) -> Bytes {