3个版本

0.1.9 2024年4月4日
0.1.8 2024年2月17日

#1711 in 网络编程

Download history 8/week @ 2024-05-19 3/week @ 2024-06-30 59/week @ 2024-07-28

每月 59 次下载
用于 boobytrap

MIT 许可

9KB
157

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".

用法

    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)
    }

开发和协作

欢迎提交拉取请求,请在提交前运行以下命令!

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

依赖

~7–18MB
~257K SLoC