20 releases

0.9.8 Aug 8, 2020
0.9.7 Jul 29, 2020
0.9.5 Jun 24, 2020
0.9.1 Mar 11, 2020
0.8.1 Nov 26, 2019

#4 in HTTP client

Download history 5677/week @ 2020-06-01 6005/week @ 2020-06-08 6407/week @ 2020-06-15 5765/week @ 2020-06-22 7820/week @ 2020-06-29 7200/week @ 2020-07-06 5539/week @ 2020-07-13 5395/week @ 2020-07-20 5692/week @ 2020-07-27 4654/week @ 2020-08-03 6831/week @ 2020-08-10 6924/week @ 2020-08-17 7883/week @ 2020-08-24 6886/week @ 2020-08-31 6694/week @ 2020-09-07 7356/week @ 2020-09-14

25,156 downloads per month
Used in 36 crates (28 directly)

MIT license

220KB
3.5K SLoC

Isahc

Say hello to Isahc (pronounced like Isaac), the practical HTTP client that is fun to use.

Formerly known as chttp.

Crates.io Documentation License Maintenance Build codecov

Key features

  • Full support for HTTP/1.1 and HTTP/2.
  • Configurable request timeouts.
  • Fully asynchronous core, with asynchronous and incremental reading and writing of request and response bodies.
  • Offers an ergonomic synchronous API as well as an asynchronous API with support for async/await.
  • Optional automatic redirect following.
  • Sessions and cookie persistence.
  • Request cancellation on drop.
  • Tweakable redirect policy.
  • Network socket configuration.
  • Uses the http crate as an interface for requests and responses.

What is Isahc?

Isahc is an acronym that stands for Incredible Streaming Asynchronous HTTP Client, and as the name implies, is an asynchronous HTTP client for the Rust language. It uses libcurl as an HTTP engine inside, and provides an easy-to-use API on top that integrates with Rust idioms.

No, who is Isahc?

Oh, you mean Isahc the dog! He's an adorable little Siberian husky who loves to play fetch with webservers every day and has a very cURLy tail. He shares a name with the project and acts as the project's mascot.

You can pet him all day if you like, he doesn't mind. Though, he prefers it if you pet him in a standards-compliant way!

Why use Isahc and not X?

Isahc provides an easy-to-use, flexible, and idiomatic Rust API that makes sending HTTP requests a breeze. The goal of Isahc is to make the easy way also provide excellent performance and correctness for common use cases.

Isahc uses libcurl under the hood to handle the HTTP protocol and networking. Using curl as an engine for an HTTP client is a great choice for a few reasons:

  • It is a stable, actively developed, and very popular library.
  • It is well-supported on a diverse list of platforms.
  • The HTTP protocol has a lot of unexpected gotchas across different servers, and curl has been around the block long enough to handle many of them.
  • It is well optimized and offers the ability to implement asynchronous requests.

Safe Rust bindings to libcurl are provided by the curl crate, which you can use yourself if you want to use curl directly. Isahc delivers a lot of value on top of vanilla curl, by offering a simpler, more idiomatic API and doing the hard work of turning the powerful multi interface into a futures-based API.

Documentation

Please check out the documentation for details on what Isahc can do and how to use it. To get you started, here is a really simple, complete example that spits out the response body from https://example.org:

use isahc::prelude::*;

fn main() -> Result<(), isahc::Error> {
    // Send a GET request and wait for the response headers.
    // Must be `mut` so we can read the response body.
    let mut response = isahc::get("http://example.org")?;

    // Print some basic info about the response to standard output.
    println!("Status: {}", response.status());
    println!("Headers: {:#?}", response.headers());

    // Read the response body as text into a string and print it.
    print!("{}", response.text()?);

    Ok(())
}

Click here for documentation on the latest version. You can also click here for built documentation from the latest unreleased master build.

Installation

Install via Cargo by adding to your Cargo.toml file:

[dependencies]
isahc = "0.9"

Supported Rust versions

The current release is only guaranteed to work with the latest stable Rust compiler. When Isahc reaches version 1.0, a more conservative policy will be adopted.

Project goals

  • Create an ergonomic and innovative HTTP client API that is easy for beginners to use, and flexible for advanced uses.
  • Provide a high-level wrapper around libcurl.
  • Maintain a lightweight dependency tree and small binary footprint.
  • Provide additional client features that may be optionally compiled in.

Non-goals:

  • Support for protocols other than HTTP.
  • Alternative engines besides libcurl. Other projects are better suited for this.

License

This project's source code and documentation are licensed under the MIT license. See the LICENSE file for details.

The Isahc logo and related assets are licensed under a Creative Commons Attribution 4.0 International License. See LICENSE-CC-BY for details.

Dependencies

~16MB
~357K SLoC