HTTP Clients

reqwest

reqwest reqwest-crates.io reqwest-github reqwest-lib.rs

reqwest is a full-fat HTTP client. It can be used in both synchronous and asynchronous code. It requires the tokio runtime.

// COMING SOON

ureq

ureq ureq-crates.io ureq-github ureq-lib.rs cat-web-programming::http-client

ureq is a minimal synchronous HTTP client, focused on simplicity and minimizing dependencies.

fn main() -> anyhow::Result<()> {
    let url = "https://jsonplaceholder.typicode.com/posts/1";
    let response: String =
        ureq::get(url).call()?.body_mut().read_to_string()?;

    println!("Response: {}", response);
    Ok(())
}

Build a HTTP Client with hyper

hyper-website hyper hyper-crates.io hyper-github hyper-lib.rs cat-network-programming cat-web-programming::http-client cat-web-programming::http-server

hyper is a HTTP/1 and HTTP/2 implementation (both client and server) that works best with the tokio async runtime, but can support other runtimes.

hyper is meant to be a low-level building block and is indeed used by higher-level libraries such as curl, reqwest, and aws-sdk. You will likely reach for hyper to design such tools or access to bleeding-edge features (like HTTP/3).

// // COMING SOON

References