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, CookieJar};

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

    // 创建自定义 Cookie 管理器
    let mut cookie_jar = CookieJar::new();
    cookie_jar.insert("session_id".to_string(), "abc123".to_string());
    cookie_jar.insert("user_token".to_string(), "xyz789".to_string());

    // 创建带有 Cookie 管理器的客户端
    let client = Client::builder()
        .cookie_jar(cookie_jar)
        .build()?;

    println!("Test 1: Request with cookies\n");
    match client.get("https://httpbin.org/cookies").await {
        Ok(response) => {
            println!("  ✓ Status: {}", response.status);
            println!("  ✓ Response:\n{}", response.text()?);
        }
        Err(e) => {
            println!("  ✗ Error: {}", e);
        }
    }

    println!("\n==================================================\n");

    println!("Test 2: Request that sets cookies\n");
    match client.get("https://httpbin.org/cookies/set?test=value").await {
        Ok(response) => {
            println!("  ✓ Status: {}", response.status);
            println!("  ✓ Response:\n{}", response.text()?);

            // 注意:Cookie 被自动存储在内部 jar 中
            println!("  ✓ Cookies stored automatically in jar");
        }
        Err(e) => {
            println!("  ✗ Error: {}", e);
        }
    }

    println!("\n==================================================\n");

    println!("Test 3: Cookie API demonstration\n");
    let mut jar = CookieJar::new();

    // 添加 Cookie
    jar.insert("name".to_string(), "value".to_string());
    jar.insert("user".to_string(), "john".to_string());

    println!("  Added 2 cookies");
    println!("  Cookie count: {}", jar.len());
    println!("  Get 'name': {:?}", jar.get("name"));

    // 构建 Cookie 头
    let cookie_header = jar.build_cookie_header();
    println!("  Cookie header: {}", cookie_header);

    // 删除 Cookie
    jar.remove("name");
    println!("  After removing 'name': {}", jar.len());

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