feat(hxprobe): httpx-based HTTP probe — full standalone package
Third Python implementation in the latency-tool progression. Mirrors latprobe's feature set but replaces raw sockets with httpx, gaining HTTP/2 support and redirect following. Package layout (hxprobe/hxprobe/): - probe.py: asyncio + httpx.AsyncClient with a _TimingStream transport wrapper that captures DNS/connect/TLS/TTFB/transfer phase timings via httpx event hooks (get_connection_stats, request_started, etc.). VerboseDetail captures resolved IP, TLS version/cipher/bits, cert CN/ expiry/issuer (from httpx's SSLObject), and response headers. Options: timeout, verbose, follow_redirects, http2 - aggregate.py: summarize() → per-phase min/avg/max (same schema as latprobe) - cli.py: run(args,stdout,stderr)->int; argparse with redirect_stdout/ redirect_stderr + SystemExit catch; -n/--count, -c/--concurrency, --timeout, --fail, --json, -v/--verbose, --no-follow-redirects, --no-http2, -f/--file (URL list from file, mutually exclusive with args); multi-URL summary footer (tally + exit label) when len(urls) > 1; worst-exit-code logic mirrors Go/latprobe; JSON output is bare array - duration.py: same parse_duration() as latprobe - Exit codes: 0 ok, 1 usage, 2 dns, 3 connect, 4 timeout, 5 tls, 6 http≥400 Tests (hxprobe/tests/): - test_probe.py: 18 hermetic tests using anyio + in-process ASGI servers - test_cli.py: 36 hermetic tests (success, failures, JSON, verbose, -f flag, run-summary footer, worst-code accumulation) - test_integration.py: pytest-marked @integration (excluded from hx-test) Toolchain: uv + ruff + pytest; pyproject.toml with [dependency-groups]; hxprobe/Makefile standalone (help, deps, run, lint, fmt, test, test-integration, check, clean); .python-version pins 3.14 Configs: 8 fixture files mirroring python/configs/ (all-ok through mixed) USAGE.md: 16 runnable examples with real captured output Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
38
hxprobe/README.md
Normal file
38
hxprobe/README.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# hxprobe
|
||||
|
||||
Per-phase HTTP latency probe built on [httpx](https://www.python-httpx.org/),
|
||||
matching Go's `http.DefaultClient`: HTTP/2 negotiated via ALPN, redirects
|
||||
followed by default, connection pooling, and default TLS verification —
|
||||
while reporting a six-phase timing breakdown (DNS, TCP connect, TLS, TTFB,
|
||||
Transfer, Total).
|
||||
|
||||
This is a fully self-contained project: no imports outside this directory,
|
||||
own `pyproject.toml`, own lockfile (`uv.lock`). It can be copied out of its
|
||||
parent repo and used standalone.
|
||||
|
||||
See [docs/usage/hxprobe.md](../docs/usage/hxprobe.md) in the parent repo for
|
||||
full flag reference, example output, and design notes (redirect semantics,
|
||||
a TTFB-accuracy finding worth knowing about).
|
||||
|
||||
## Quick start
|
||||
|
||||
Requires [uv](https://docs.astral.sh/uv/).
|
||||
|
||||
```sh
|
||||
uv sync # create .venv, install deps + lockfile
|
||||
uv run python -m hxprobe https://example.com
|
||||
uv run python -m hxprobe -v http://github.com # verbose: shows HTTP/2, redirects, TLS, cert
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
```sh
|
||||
uv run pytest tests -m "not integration" -v # hermetic unit tests
|
||||
uv run pytest tests -m integration -v # live tests (hits the real internet)
|
||||
uv run ruff check . # lint
|
||||
uv run ruff format . # format
|
||||
```
|
||||
|
||||
From the parent repo's root, the equivalent Makefile targets are
|
||||
`make hx-run`, `make hx-test`, `make hx-test-integration`, `make hx-lint`,
|
||||
`make hx-fmt`, and `make hx-check` (lint + hermetic tests).
|
||||
Reference in New Issue
Block a user