17 releases (10 breaking)

✓ Uses Rust 2018 edition

0.13.0 Apr 24, 2020
0.12.0 Mar 11, 2020
0.11.1 Jan 29, 2020
0.8.0 Dec 29, 2019
0.4.1 Mar 23, 2019

#6 in HTTP client

Download history 3574/week @ 2020-02-09 2685/week @ 2020-02-16 1984/week @ 2020-02-23 2616/week @ 2020-03-01 3732/week @ 2020-03-08 4712/week @ 2020-03-15 6074/week @ 2020-03-22 3352/week @ 2020-03-29 5189/week @ 2020-04-05 4590/week @ 2020-04-12 4780/week @ 2020-04-19 5966/week @ 2020-04-26 5102/week @ 2020-05-03 7008/week @ 2020-05-10 6212/week @ 2020-05-17 6784/week @ 2020-05-24

17,418 downloads per month
Used in 32 crates (22 directly)

MPL-2.0 license

110KB
2.5K SLoC

Ruby 2.5K SLoC // 0.2% comments Scheme 9 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, eventually HTTP/2.0
  • 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

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
  • TLS
  • Automatic redirection
  • Streaming response body
  • Text encoding support
  • Gzip, deflate support
  • Transfer-Encoding: chunked
  • serde support behind a feature flag
  • Authentication (partial support)
  • Happy Eyeballs

Features being worked on

  • File upload, form data
  • Thorough test suite
  • Connection: keep-alive

License

This project is licensed under the MPL-2.0.

Dependencies

~1.8–6MB
~145K SLoC