#http-request #response #client #request

http_req

simple and lightweight HTTP client with built-in HTTPS support

47 releases

0.13.3 Apr 7, 2025
0.13.2 Mar 30, 2025
0.13.1 Dec 6, 2024
0.13.0 Oct 14, 2024
0.3.1 Nov 21, 2018

#32 in HTTP client

Download history 843/week @ 2024-12-27 1154/week @ 2025-01-03 1343/week @ 2025-01-10 1367/week @ 2025-01-17 1263/week @ 2025-01-24 1410/week @ 2025-01-31 2536/week @ 2025-02-07 1427/week @ 2025-02-14 1754/week @ 2025-02-21 1577/week @ 2025-02-28 1879/week @ 2025-03-07 1898/week @ 2025-03-14 1670/week @ 2025-03-21 1586/week @ 2025-03-28 1695/week @ 2025-04-04 1382/week @ 2025-04-11

6,771 downloads per month
Used in 51 crates (27 directly)

MIT license

135KB
3K SLoC

http_req

Rust Crates.io Docs.rs

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

  • HTTP and HTTPS via rust-native-tls (or optionally rus-tls)
  • Small binary size (0.7 MB for a basic GET request in the default configuratio)
  • Minimal number of dependencies

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

Usage

Default configuration

In order to use http_req with default configuration, add the following lines to Cargo.toml:

[dependencies]
http_req = "^0.13"

Rustls

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

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

License

Licensed under MIT.

Dependencies

~0.6–12MB
~167K SLoC