20个版本
0.2.18 | 2022年12月4日 |
---|---|
0.2.17 | 2022年9月10日 |
0.2.15 | 2022年8月19日 |
0.2.10 | 2021年7月29日 |
0.1.0 | 2019年3月13日 |
#9 in #limited
每月195次下载
在4个crate(2个直接)中使用
125KB
3.5K SLoC
http_io 
包含HTTP客户端和服务器的crate。
- 设计为具有有限的依赖关系,支持
#![no_std]
。 - 专注于流式IO。
- 支持提供自己的传输。
- 支持HTTPS
no_std构建需要nightly,因为它依赖于alloc crate。
示例
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(())
}
选择TLS后端
默认情况下,http_io
使用native-tls
作为其TLS库(HTTPS支持)。它还支持其他两个TLS库,rustls
和openssl
。这些其他“后端”可以通过功能选择
$ # 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
依赖
~0.8–12MB
~152K SLoC