Skip to content

A simple library to measure the key HTTP timings from the development tools

License

Notifications You must be signed in to change notification settings

metrixweb/http-timings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

http-timings: A library to measure HTTP timings

Inspired by the libraries TTFB by phip1611 and ssl-expiration by onur. This library provides the following information from any given URL:

  • Status code
  • Body of the response
  • SSL Certificate information
  • DNS Lookup Time
  • TCP Connection Time
  • TLS Handshake Time
  • HTTP Send Time
  • Time to First Byte
  • Content Download Time

Usage

use http_timings::from_string;

let url = "https://www.example.com";
let timeout = Some(Duration::from_secs(5)); // Set a timeout of 5 seconds
match from_string(url, timeout) {
    Ok(response) => {
        println!("Response Status: {}", response.status);
        println!("Response Body: {}", response.body);
        if let Some(cert_info) = response.certificate_information {
            println!("Certificate Subject: {:?}", cert_info.subject);
            println!("Certificate Issued At: {:?}", cert_info.issued_at);
            println!("Certificate Expires At: {:?}", cert_info.expires_at);
            println!("Is Certificate Active: {:?}", cert_info.is_active);
        } else {
            println!("No certificate information available.");
        }
    },
    Err(e) => {
        eprintln!("Error occurred: {:?}", e);
    }
}

The Response struct provides all the information about the request. The timings in both relative and total terms. The relative timings are the time taken for each step of the request, while the total timings are the time taken from the start of the request to the end of the request.

The URL input can be any valid website as well as any valid IP.

About

A simple library to measure the key HTTP timings from the development tools

Resources

License

Stars

Watchers

Forks

Languages