20 releases (13 breaking)

0.16.0 Oct 12, 2020
0.15.0 Jun 29, 2020
0.14.0 Jun 6, 2020
0.12.0 Mar 11, 2020
0.4.1 Mar 23, 2019

#4 in HTTP client

Download history 9089/week @ 2020-07-05 10155/week @ 2020-07-12 8216/week @ 2020-07-19 7810/week @ 2020-07-26 7994/week @ 2020-08-02 8540/week @ 2020-08-09 6583/week @ 2020-08-16 7209/week @ 2020-08-23 5492/week @ 2020-08-30 5097/week @ 2020-09-06 5099/week @ 2020-09-13 5503/week @ 2020-09-20 6331/week @ 2020-09-27 7144/week @ 2020-10-04 9472/week @ 2020-10-11 8699/week @ 2020-10-18

28,982 downloads per month
Used in 60 crates (34 directly)

MPL-2.0 license

130KB
3K SLoC

attohttpc

Documentation | Crates.io | Repository

Why attohttpc?

This project's goal is to provide a lightweight and simple HTTP client for the Rust ecosystem. The intended use is for projects that have HTTP needs where performance is not critical or when HTTP is not the main purpose of the application. Note that the project still tries to perform well and avoid allocation where possible, but stays away from Rust's asynchronous stack to provide a crate that's as small as possible. Features are provided behind feature flags when possible to allow users to get just what they need. Here are the goals of the project:

  • Lightweight
  • Secure
  • Easy to use
  • Modular
  • HTTP/1.1
  • Use quality crates from the ecosystem (http, url, encoding_rs), not reinventing the wheel.

Features

  • charsets support for decoding more text encodings than just UTF-8
  • compress support for decompressing response bodies (default)
  • json support for serialization and deserialization
  • form support for url encoded forms (does not include support for multipart)
  • tls support for tls connections (default)
  • tls-rustls support for TLS connections using rustls instead of native-tls
  • multipart-form support for multipart forms (does not include support for url encoding)

Usage

See the examples/ folder in the repository for more use cases.

let resp = attohttpc::post("https://my-api.com/do/something").json(&request)?.send()?;
if resp.is_success() {
    let response = resp.json()?;
    // ...
}

Current feature set

  • Query parameters, Request headers, Bodies, etc.
  • TLS, adding trusted certificates, disabling verification, etc. for both native-tls and rustls
  • Automatic redirection
  • Streaming response body
  • Multiple text encodings
  • Automatic compression/decompression with gzip or deflate
  • Transfer-Encoding: chunked
  • serde/json support
  • HTTP Proxies & HTTP_PROXY, HTTPS_PROXY, NO_PROXY environment variables.
  • Happy Eyeballs
  • Authentication (partial support)

License

This project is licensed under the MPL-2.0.

Dependencies

~2–7MB
~178K SLoC