httping

Crates.iohttping
lib.rshttping
version0.1.9
sourcesrc
created_at2024-02-16 20:17:38.924422
updated_at2024-04-04 19:00:28.919649
descriptionPing for HTTP/s
homepage
repositoryhttps://github.com/helloimalemur/httping
max_upload_size
id1142767
size10,869
helloimalemur (helloimalemur)

documentation

README

httping

Httping is like 'ping' but for http-requests.
Provide a URL or IP address, plus the HTTP/HTTPS port number.
Returns with a bool indicating success or failure of the ping,
as well as how long it takes to connect send a request and retrieve
the full response (headers + body) which is returned as an integer "rtt".

Usage

    async fn ping_bool() {
        let wrapped_result = ping("koonts.net", "", "http", 80).await;
        let result = wrapped_result.unwrap();
        println!("{:#?}", result);
        assert_eq!(result, true);
    }

    async fn ping_bool_ip() {
        let wrapped_result = ping("", "96.30.198.61", "http", 80).await;
        let result = wrapped_result.unwrap();
        println!("{:#?}", result);
        assert_eq!(result, true);
    }

    async fn ping_bool_https() {
        let wrapped_result = ping("koonts.net", "", "https", 443).await;
        let result = wrapped_result.unwrap();
        println!("{:#?}", result);
        assert_eq!(result, true);
    }
    
    async fn ping_bool_ip_https() {
        let wrapped_result = ping("", "96.30.198.61", "https", 443).await;
        let result = wrapped_result.unwrap();
        println!("{:#?}", result);
        assert_eq!(result, true);
    }

    async fn ping_full() {
        let wrapped_result = ping_with_metrics("koonts.net", "", "http", 80).await;
        let result = wrapped_result.unwrap();
        let success = result.success;
        let rtt = result.rtt;
        println!("{:#?}", result);
        assert_eq!(success, true);
        assert!(rtt > 0)
    }

Development and Collaboration

Feel free to open a pull request, please run the following prior to your submission please!

echo "Run clippy"; cargo clippy -- -D clippy::all
echo "Format source code"; cargo fmt -- --check
Commit count: 36

cargo fmt