#http-request #http #request #client

http_req

simple and lightweight HTTP client with built-in HTTPS support

40 releases

new 0.10.3 Apr 21, 2024
0.10.2 Dec 1, 2023
0.10.1 Oct 29, 2023
0.9.2 Jul 7, 2023
0.3.1 Nov 21, 2018

#66 in HTTP client

Download history 1954/week @ 2024-01-03 1983/week @ 2024-01-10 3245/week @ 2024-01-17 3530/week @ 2024-01-24 2888/week @ 2024-01-31 2205/week @ 2024-02-07 1888/week @ 2024-02-14 2018/week @ 2024-02-21 2600/week @ 2024-02-28 1604/week @ 2024-03-06 1532/week @ 2024-03-13 2086/week @ 2024-03-20 2092/week @ 2024-03-27 2453/week @ 2024-04-03 2107/week @ 2024-04-10 1479/week @ 2024-04-17

8,408 downloads per month
Used in 48 crates (24 directly)

MIT license

115KB
2.5K SLoC

http_req

Rust Crates.io Docs.rs

Simple and lightweight HTTP client with built-in HTTPS support.

Requirements

http_req by default uses rust-native-tls, which relies on TLS framework provided by OS on Windows and macOS, and OpenSSL on all other platforms. But it also supports rus-tls.

Example

Basic HTTP GET request

use http_req::request;

fn main() {
    let mut body = Vec::new(); //Container for body of a response.
    let res = request::get("https://doc.rust-lang.org/", &mut body).unwrap();

    println!("Status: {} {}", res.status_code(), res.reason());
}

Take a look at more examples

How to use with rustls:

In order to use http_req with rustls in your project, add the following lines to Cargo.toml:

[dependencies]
http_req  = {version="^0.10", default-features = false, features = ["rust-tls"]}

License

Licensed under MIT.

Dependencies

~0.2–12MB
~130K SLoC