3 releases

0.1.9 Apr 4, 2024
0.1.8 Feb 17, 2024

#1632 in Network programming

Download history 277/week @ 2024-02-15 50/week @ 2024-02-22 23/week @ 2024-02-29 4/week @ 2024-03-07 3/week @ 2024-03-14 2/week @ 2024-03-28 88/week @ 2024-04-04 3/week @ 2024-04-11

93 downloads per month

MIT license

9KB
157 lines

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

Dependencies

~7–19MB
~276K SLoC