Skip to content

Conversation

@jpopesculian
Copy link
Contributor

I started implementing this feature because I realized RequestInit takes a ReadableStream as a body but then I realized half way through that the browser support isn't great. But I've finished it anyways if you want to use it or just for reference. I've tested it locally with

#[derive(serde::Deserialize, Debug)]
struct HttpBinResponse {
    data: String,
}

#[wasm_bindgen_test]
pub async fn test() {
    let chunks: Vec<Result<_, ::std::io::Error>> = vec![Ok("hello"), Ok(" "), Ok("world")];
    let stream = futures_util::stream::iter(chunks);
    let body = reqwest::Body::wrap_stream(stream);
    let res = reqwest::Client::new()
        .post("https://nghttp2.org/httpbin/post")
        .body(body)
        .send()
        .await
        .unwrap()
        .json::<HttpBinResponse>()
        .await
        .unwrap();
    assert_eq!(res.data, "hello world");
}

@jpopesculian jpopesculian force-pushed the feat-wasm-streaming-body branch from 7212248 to 0e37a0a Compare June 19, 2025 13:07
@jpopesculian jpopesculian force-pushed the feat-wasm-streaming-body branch from 0e37a0a to b4fd93f Compare June 26, 2025 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant