#ntex #stream #reqwest #adaptor

clia-reqwest-ntex-stream

A Stream to link between Reqwest and ntex two systems

1 stable release

1.0.1 Mar 24, 2022
1.0.0 Mar 22, 2022

#18 in #ntex

BSD-2-Clause

9KB
73 lines

clia-reqwest-ntex-stream

A Stream to link between Reqwest and ntex two systems.

PayloadStream Example

async fn handle(
    body: ntex::web::types::Payload,
) {
    let mut builder = client.get(url);
    // This stream is not for send between threads, otherwise it's unsafe.
    builder = builder.body(reqwest::Body::wrap_stream(reqwest_ntex_stream::PayloadStream {
        payload: body,
    }));
    builder.send().await;
}

ResponseStream Example

let res = builder.send().await;
let stream = res.bytes_stream();
let mut resp = HttpResponse::build(res.status());
// This method will use chunked Transfer-Encoding, otherwise use ntex::http::body::SizedStream
return Ok(resp.streaming(reqwest_ntex_stream::ResponseStream{ stream: stream }));

Dependencies

~17–32MB
~596K SLoC