4 releases

0.11.16 Nov 15, 2023
0.11.15 Apr 19, 2023
0.11.14 Feb 5, 2023
0.11.12 Oct 2, 2022

#68 in WebAssembly

Download history 259/week @ 2024-01-13 95/week @ 2024-01-20 228/week @ 2024-01-27 89/week @ 2024-02-03 101/week @ 2024-02-10 118/week @ 2024-02-17 205/week @ 2024-02-24 234/week @ 2024-03-02 208/week @ 2024-03-09 155/week @ 2024-03-16 207/week @ 2024-03-23 313/week @ 2024-03-30 350/week @ 2024-04-06 234/week @ 2024-04-13 599/week @ 2024-04-20 325/week @ 2024-04-27

1,589 downloads per month
Used in 12 crates (11 directly)

MIT/Apache

525KB
10K SLoC

reqwest for WebAssembly

An ergonomic, batteries-included HTTP Client for Rust. This is a fork from the original reqwest with support for WebAssembly compilation target. That allows reqwest apps to run inside the WasmEdge Runtime as a lightweight and secure alternative to natively compiled apps in Linux container.

For more details and usage examples, please see the upstream reqwest source and these examples.

Note: We do not yet support SSL / TLS connections in reqwest_wasi yet.

  • Plain bodies, JSON, urlencoded, multipart
  • Customizable redirect policy
  • HTTP Proxies
  • Cookie Store

Example

This asynchronous example uses Tokio and enables some optional features, so your Cargo.toml could look like this:

[dependencies]
reqwest_wasi = { version = "0.11", features = ["json"] }
tokio_wasi = { version = "1.21", features = ["full"] }

And then the code:

use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let resp = reqwest::get("http://eu.httpbin.org/ip")
        .await?
        .json::<HashMap<String, String>>()
        .await?;
    println!("{:#?}", resp);
    Ok(())
}

Blocking Client

There is an optional "blocking" client API that can be enabled:

[dependencies]
reqwest_wasi = { version = "0.11", features = ["blocking", "json"] }
use std::collections::HashMap;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let resp = reqwest::blocking::get("http://eu.httpbin.org/ip")?
        .json::<HashMap<String, String>>()?;
    println!("{:#?}", resp);
    Ok(())
}

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~3–23MB
~432K SLoC