ugi 0.2.1

Runtime-agnostic Rust request client with HTTP/1.1, HTTP/2, HTTP/3, H2C, WebSocket, SSE, and gRPC support
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use futures_lite::future::block_on;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    block_on(async move {
        let client = ugi::Client::builder()
            .compression_mode(ugi::CompressionMode::Manual)
            .build()?;

        let response = client
            .get("https://download.example.com/archive")
            .header("accept-encoding", "gzip")?
            .await?;
        let compressed = response.bytes().await?;

        println!("downloaded {} compressed bytes", compressed.len());
        Ok(())
    })
}