Crate alhc

source ·
Expand description

Async Lightweight HTTP Client (aka ALHC)

What if we need async but also lightweight http client without using such a large library like reqwest, isahc or surf?

ALHC is a async http client library that using System library to reduce binary size and provide async request feature.

HTTPS Example:

use alhc::prelude::*;
use alhc::*;

use pollster::FutureExt;

fn main() -> DynResult {
    let client = get_client_builder().build().unwrap();

    let r = client
        .header("user-agent", "alhc/0.2.0")
        .body_string("Hello World!".repeat(20))



Our little request example https with release build can be 182 KB, which is smaller than tinyget’s http example. If we use rustc nightly feature plus build-std and panic_immediate_abort, it’ll be incredibly 60 KB!

Currently work in progress and only support Windows (Using WinHTTP) and macOS in progress (Using CFNetwork), linux are being planned.

Platform Status

MacOSWorkingMaybe failed sometime or very slow (To be fixed)
LinuxUnder Development


  • async_t_boxed: Use async-trait instead of async-t, which requires nightly rustc but with zero-cost. Default is enabled.
  • serde: Can give you the ability of send/receive json data without manually call serde_json. Default is disabled.

Compilation binary size comparison

Note: the size optimization argument is: cargo +nightly run --release -Z build-std=core,alloc,std,panic_abort -Z build-std-features=panic_immediate_abort --target [TARGET] --example [EXAMPLE] and some configuration in Cargo.toml

NameWindows (x86_64)Windows (i686)Windows (aarch64)macOS (x86_64)macOS (aarch64)Linux (x86_64)
example https397,824284,160296,9601,044,0081,250,051WIP
example https release181,760187,904200,192596,040570,515/
example https release with size optimization60,41652,22459,39288,73689,048/
example parallel520,704376,320393,2161,321,1921,573,398/
example parallel release195,072211,456229,888627,760619,702/
example parallel release with size optimization66,56058,88066,560105,208105,784/
example sequential402,432289,280302,0801,041,4241,244,408/
example sequential release185,344191,488203,264593,072566,888/
example sequential release with size optimization62,46454,78460,92888,77689,224/





Type Definitions