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 7499721a10 - Show all commits

View file

@ -200,7 +200,7 @@ fn u8_to_io_error(v: u8) -> std::io::Error {
} }
fn io_error_to_u8(e: std::io::Error) -> u8 { fn io_error_to_u8(e: std::io::Error) -> u8 {
use std::io::{ErrorKind}; use std::io::ErrorKind;
match e.kind() { match e.kind() {
ErrorKind::ConnectionAborted => 101, ErrorKind::ConnectionAborted => 101,
ErrorKind::BrokenPipe => 102, ErrorKind::BrokenPipe => 102,
@ -217,8 +217,7 @@ fn io_error_to_u8(e: std::io::Error) -> u8 {
} }
pub fn asyncread_stream<R: AsyncRead + Send + Sync + 'static>(reader: R) -> ByteStream { pub fn asyncread_stream<R: AsyncRead + Send + Sync + 'static>(reader: R) -> ByteStream {
Box::pin(tokio_util::io::ReaderStream::new(reader) Box::pin(tokio_util::io::ReaderStream::new(reader).map_err(io_error_to_u8))
.map_err(io_error_to_u8))
} }
pub fn stream_asyncread(stream: ByteStream) -> impl AsyncRead + Send + Sync + 'static { pub fn stream_asyncread(stream: ByteStream) -> impl AsyncRead + Send + Sync + 'static {