#http-request #http #request #client

http_req

simple and lightweight HTTP client with built-in HTTPS support

45 releases

new 0.13.1 Dec 6, 2024
0.13.0 Oct 14, 2024
0.12.0 Aug 17, 2024
0.11.1 Jul 28, 2024
0.3.1 Nov 21, 2018

#40 in HTTP client

Download history 1691/week @ 2024-08-22 1591/week @ 2024-08-29 1636/week @ 2024-09-05 2868/week @ 2024-09-12 2367/week @ 2024-09-19 2023/week @ 2024-09-26 2005/week @ 2024-10-03 2341/week @ 2024-10-10 2022/week @ 2024-10-17 1647/week @ 2024-10-24 1929/week @ 2024-10-31 2153/week @ 2024-11-07 1943/week @ 2024-11-14 1891/week @ 2024-11-21 1825/week @ 2024-11-28 1373/week @ 2024-12-05

7,321 downloads per month
Used in 49 crates (26 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 basic GET request in default configuration)
  • Minimal amount 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–11MB
~150K SLoC