net_benchmark.http_bench.core
Core HTTP benchmarking functionality.
Classes
|
|
|
Negotiated application protocol — captured from the live connection. |
|
Result of a single HTTP request |
|
AsyncHTTPTransport that captures per-connection timing and TLS metrics. |
|
Parse and validate HTTP target URLs. |
|
Wraps AutoBackend to inject per-connection TCP and TLS timing. |
|
Wraps an AsyncNetworkStream to capture TCP-connect and TLS-handshake times. |
- class net_benchmark.http_bench.core.TimingNetworkStream(stream, metrics)[source]
Bases:
AsyncNetworkStreamWraps an AsyncNetworkStream to capture TCP-connect and TLS-handshake times.
The metrics dict is shared with TimingNetworkBackend so writes made inside start_tls() are immediately visible there without any extra plumbing.
- class net_benchmark.http_bench.core.TimingNetworkBackend(local_address=None)[source]
Bases:
AsyncNetworkBackendWraps AutoBackend to inject per-connection TCP and TLS timing.
One backend instance per origin so metrics are not clobbered across origins.
- async connect_tcp(host, port, timeout=None, local_address=None, socket_options=None)[source]
- Return type:
AsyncNetworkStream
- class net_benchmark.http_bench.core.MetricsCapturingTransport(verify=True, cert=None, http2=False, sni_hostname=None, mtls_cert=None, mtls_key=None, local_address=None)[source]
Bases:
AsyncHTTPTransportAsyncHTTPTransport that captures per-connection timing and TLS metrics.
Rather than overriding the non-existent _init_pool hook, we build the httpcore.AsyncConnectionPool ourselves and pass the custom TimingNetworkBackend directly.
- class net_benchmark.http_bench.core.HTTPProtocol(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
-
Negotiated application protocol — captured from the live connection.
- HTTP1 = 'HTTP/1.1'
- HTTP2 = 'HTTP/2'
- UNKNOWN = 'unknown'
- class net_benchmark.http_bench.core.HTTPResult(target, method, start_time, end_time, total_ms, status, iteration=1, attempt_number=1, query_id=<factory>, http_status_code=None, error_message=None, redirect_count=0, final_url='', ttfb_ms=None, ttlb_ms=None, protocol=HTTPProtocol.UNKNOWN, alpn_negotiated=None, response_size_bytes=None, compressed=False, content_encoding=None, content_type=None, security_headers=<factory>, cdn_fingerprint=None, server_header=None, cert_expiry_days=None, cert_cn=None, alt_svc=None, ip_version=None, cert_issuer_cn=None, cert_sans=<factory>, cert_wildcard=False, downgrade_detected=False, redirect_urls=<factory>, tls_handshake_ms=None, tcp_connect_ms=None, dns_resolve_ms=None, dns_resolver_ip=None, compressed_size_bytes=None, http2_expected=False, http2_downgraded=False, redirect_timings=<factory>, query_params=<factory>, cache_control=None, etag=None, last_modified=None, age=None, request_id=None, assertion_results=<factory>)[source]
Bases:
objectResult of a single HTTP request
-
status:
QueryStatus
-
protocol:
HTTPProtocol= 'unknown'
-
status:
- class net_benchmark.http_bench.core.TargetManager(targets)[source]
Bases:
objectParse and validate HTTP target URLs.
-
DEFAULT_TARGETS:
List[str] = ['https://www.cloudflare.com', 'https://www.google.com', 'https://www.github.com', 'https://www.wikipedia.org', 'https://www.apple.com']
-
DEFAULT_TARGETS:
- class net_benchmark.http_bench.core.HTTPBenchmarkEngine(max_concurrent=50, timeout=10.0, connect_timeout=None, read_timeout=None, write_timeout=None, max_retries=2, retry_backoff_multiplier=0.1, retry_backoff_base=2.0, method='GET', headers=None, follow_redirects=True, verify_ssl=True, http2=True, auth=None, cookies=None, proxy=None, sni_hostname=None, mtls_cert=None, mtls_key=None, inject_request_id=False, assertions=None, query_params=None, body=None, local_address=None)[source]
Bases:
object- async request_single(target, iteration=1)[source]
Execute a single HTTP request with retry logic.
- Return type: