#client-server #http-server #tls #limited #https #io

no-std http_io

A library with limited dependencies containing an HTTP client and server

21 releases

0.3.0 Nov 20, 2024
0.2.18 Dec 4, 2022
0.2.17 Sep 10, 2022
0.2.10 Jul 29, 2021
0.1.0 Mar 13, 2019

#101 in HTTP client

Download history 1/week @ 2024-09-11 11/week @ 2024-09-18 32/week @ 2024-09-25 16/week @ 2024-10-02 2/week @ 2024-10-09 1/week @ 2024-10-16 2/week @ 2024-10-30 3/week @ 2024-11-06 1/week @ 2024-11-13 163/week @ 2024-11-20 5/week @ 2024-11-27

173 downloads per month
Used in 5 crates (2 directly)

MIT/Apache

130KB
3.5K SLoC

http_io Latest Version

Crate containing HTTP client and server.

  • Designed to have limited dependencies, supports #![no_std].
  • Focus on streaming IO.
  • Support for providing your own transport.
  • Supports HTTPS

The no_std build requires nightly since it relies on the alloc crate.

Example

use http_io::error::Result;
use std::fs::File;
use std::io;

fn main() -> Result<()> {
    // Stream contents of url to stdout
    let mut body = http_io::client::get("https://postman-echo.com/get")?;
    io::copy(&mut body, &mut std::io::stdout())?;

    // Stream contents of file to remote server
    let file = File::open("src/client.rs")?;
    http_io::client::put("https://postman-echo.com/put", file)?;
    Ok(())
}

Choosing a TLS backend

By default http_io uses native-tls as its library for TLS (HTTPS support). It supports two other TLS libraries, rustls and openssl. These other "back-ends" can be selected using feaures

$ # If you want to use `rustls`:
$ cargo build --no-default-features --features std,ssl-rustls
$ # If you want to use `openssl`:
$ cargo build --no-default-features --features std,ssl-openssl

Dependencies

~3–15MB
~220K SLoC