nadzoring.network_base.http_ping module¶
HTTP/HTTPS response timing and diagnostics.
- class nadzoring.network_base.http_ping.HttpPingResult(url: str, final_url: str | None, status_code: int | None, dns_ms: float | None, ttfb_ms: float | None, total_ms: float | None, content_length: int | None, headers: dict[str, str]=<factory>, error: str | None = None)[source]¶
Bases:
objectResult of a single HTTP ping operation.
- __init__(url: str, final_url: str | None, status_code: int | None, dns_ms: float | None, ttfb_ms: float | None, total_ms: float | None, content_length: int | None, headers: dict[str, str]=<factory>, error: str | None = None) None[source]¶
- content_length: int | None¶
- dns_ms: float | None¶
- error: str | None = None¶
- final_url: str | None¶
- headers: dict[str, str]¶
- status_code: int | None¶
- total_ms: float | None¶
- ttfb_ms: float | None¶
- url: str¶
- nadzoring.network_base.http_ping._measure_dns(hostname: str) float | None[source]¶
Measure DNS resolution time in milliseconds.
- Parameters:
hostname – Hostname to resolve.
- Returns:
Resolution time in milliseconds, or None if resolution failed.
- nadzoring.network_base.http_ping.http_ping(url: str, timeout_config: TimeoutConfig | None = None, *, verify_ssl: bool = True, follow_redirects: bool = True, include_headers: bool = True) HttpPingResult[source]¶
Perform an HTTP request and collect detailed timing metrics.
Measures DNS resolution time separately, then tracks time-to-first-byte (TTFB) and total download duration using streaming response mode.
- Parameters:
url – Target URL to probe. HTTP scheme is added if missing.
timeout_config – Unified timeout config. If is
None, set default timeouts.verify_ssl – Whether to verify SSL certificates. Defaults to True.
follow_redirects – Whether to follow HTTP redirects. Defaults to True.
include_headers – Whether to include response headers. Defaults to True.
- Returns:
HttpPingResult with timing breakdown and response metadata.
Examples
>>> result = http_ping("https://example.com") >>> result.status_code 200