tomcat 0.1.0

Easy to send HTTP/HTTPS requests
Documentation

Easy to send HTTP/HTTPS requests.

Crates.io Rust license

Examples


non-blocking

#[tokio::main]
async fn main(){
    if let Ok(res) = get("https://www.spacex.com").await{
        assert_eq!(200,res.status);
        assert_eq!(r#"{"content-type": "text/html; charset=utf-8", "vary": "Accept-Encoding", "date": "Sun, 09 Oct 2022 18:49:44 GMT", "connection": "keep-alive", "keep-alive": "timeout=5", "transfer-encoding": "chunked"}"#,format!("{:?}",res.headers));
        println!("{}",res.text);
        println!("{}",res.text_with_charset);
        println!("{}",res.url);
        println!("{}",res.remote_addr);
        println!("{:?}",res.version);
    }
    
}

blocking

fn main(){
    use tomcat::*;
    if let Ok(res) = get_blocking("https://www.spacex.com"){
        assert_eq!(200,res.status);
        assert_eq!(r#"{"content-type": "text/html; charset=utf-8", "vary": "Accept-Encoding", "date": "Sun, 09 Oct 2022 18:49:44 GMT", "connection": "keep-alive", "keep-alive": "timeout=5", "transfer-encoding": "chunked"}"#,format!("{:?}",res.headers));
        println!("{}",res.text);
        println!("{}",res.text_with_charset);
        println!("{}",res.url);
        println!("{}",res.remote_addr);
        println!("{:?}",res.version);
    }
}