clia-reqwest-ntex-stream

Crates.ioclia-reqwest-ntex-stream
lib.rsclia-reqwest-ntex-stream
version1.0.1
sourcesrc
created_at2022-03-22 12:43:32.189044
updated_at2022-03-24 13:27:47.6181
descriptionA Stream to link between Reqwest and ntex two systems.
homepage
repositoryhttps://github.com/clia/reqwest-ntex-stream
max_upload_size
id554671
size10,717
clia (clia)

documentation

README

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 }));
Commit count: 13

cargo fmt