GitHub Contributors Stars Build Status Downloads Crates.io

HttpClient

httpclient is a user-friendly http client in Rust. Where possible, it closely mimics the reqwest API. Why build a new http client?

Note: httpclient is under active development and is alpha quality software. While we make effort not to change public APIs, we do not currently provide stability guarantees.

Examples

```rust

[tokio::main]

async fn main() { let mut client = httpclient::Client::new() // With this middleware, the script will only make the request once. After that, it replays from the filesystem // and does not hit the remote server. The middleware has different modes to ignore recordings (to force refresh) // and to prevent new requests (for running a test suite). // The recordings are sanitized to hide secrets. .with_middleware(httpclient::middleware::RecorderMiddleware::new()) ; let res = client.get("https://www.jsonip.com/") .header("secret", "foo") .await .unwrap(); // Note the default API (identical to reqwest) requires awaiting the response body. let res = res.text().await.unwrap();

let res = client.get("https://www.jsonip.com/")
    .header("secret", "foo")
    .send_awaiting_body()
    .await
    .unwrap();
// By using `send_awaiting_body`, the response is loaded into memory, and we don't have to `await` it.
let res = res.text().unwrap();

} ```

Roadmap