ugi 0.2.1

Runtime-agnostic Rust request client with HTTP/1.1, HTTP/2, HTTP/3, H2C, WebSocket, SSE, and gRPC support
Documentation
#[cfg(feature = "emulation")]
use futures_lite::future::block_on;
#[cfg(feature = "emulation")]
use serde_json::Value;

#[cfg(feature = "emulation")]
fn main() -> Result<(), Box<dyn std::error::Error>> {
    block_on(async move {
        let client = ugi::Client::builder()
            .emulation(ugi::Emulation::Chrome136)
            .build()?;

        let response = client.get("https://tls.peet.ws/api/all").await?;
        let payload: Value = response.json().await?;

        println!(
            "http_version={}",
            payload["http_version"].as_str().unwrap_or("unknown")
        );
        println!(
            "user_agent={}",
            payload["user_agent"].as_str().unwrap_or("unknown")
        );
        Ok(())
    })
}

#[cfg(not(feature = "emulation"))]
fn main() {
    eprintln!(
        "This example requires the `emulation` feature:\n  cargo run --example emulation_preset --features emulation"
    );
}