reqres 1.0.0

A pure Rust async HTTP client library based on Tokio with HTTP/2, connection pooling, proxy, cookie, compression, benchmarks, and comprehensive tests
Documentation
use reqres::Client;
use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!("=== reqres v0.4.0 HTTPS Client Demo ===\n");

    // 使用 ClientBuilder 创建配置化的客户端
    let client = Client::builder()
        .timeout(Duration::from_secs(30))
        .follow_redirects(true)
        .max_redirects(5)
        .user_agent("reqres/0.2.0 (HTTPS Demo)")
        .build()?;

    // HTTPS GET 请求示例
    println!("Sending HTTPS GET request to httpbin.org...");
    match client.get("https://httpbin.org/get").await {
        Ok(response) => {
            println!("✓ HTTPS GET request successful!");
            println!("  Status: {} {}", response.status(), response.status_text);
            println!("  Headers:");
            for (key, value) in &response.headers {
                println!("    {}: {}", key, value);
            }
            println!("\n  Body preview (first 500 chars):");
            let body_text = response.text().unwrap_or_default();
            let body_preview = if body_text.len() > 500 {
                &body_text[..500]
            } else {
                &body_text
            };
            println!("{}", body_preview);
        }
        Err(e) => {
            eprintln!("✗ HTTPS GET request failed: {}", e);
        }
    }

    println!("\n{}\n", &"=".repeat(50));

    // 测试重定向
    println!("Testing redirect handling...");
    match client.get("https://httpbin.org/redirect/3").await {
        Ok(response) => {
            println!("✓ Redirect handled successfully!");
            println!("  Final Status: {}", response.status());
        }
        Err(e) => {
            eprintln!("✗ Redirect test failed: {}", e);
        }
    }

    println!("\n=== Demo completed ===");
    Ok(())
}