perf(net): migrate first-party HTTP clients to HTTPX2

FA
1h ago
+328-141

Why

Migrate Reflex's own HTTP requests to HTTPX2 so they use the transport with cached optional sniffio detection. The minimum version also includes the Linux TLS context CPU fix.

What changed

  • Require httpx2>=2.15.1,<3.0 in Reflex, the hosting CLI, and the shared website backend; lock HTTPX2/httpcore2 to 2.16.0.
  • Drop httpx from Reflex's dependencies; docs snippets now use httpx2.
  • Migrate imports, exception handling, and tests; select the SDK's existing [httpx2] transport extra and raise Reflex's hosting CLI floor.
  • Add proxy/NO_PROXY and connection-error coverage, a CLI regression test with legacy HTTPX imports disabled, migration docs, and package changelogs.

Scope

First-party HTTP callers and their tests. The SDK's explicitly selected legacy HTTPX transport remains supported.

Blast Radius

HTTPS uses the operating system's certificate store. Custom CA settings and proxy environment variables remain supported. Reflex no longer installs legacy httpx. Code that imports it without declaring it breaks until it declares httpx or migrates: known cases are reflex-google-auth (fails rx-shout-from-template CI), the api_admin_panel template, and reflex-examples (github-stats, basic_crud).

Verification

  • Full unit suite: 16,468 passed, 74 skipped; 82.43% coverage.
  • All pre-commit hooks applicable to changed files passed; repository-wide Ruff and pyright reflex tests passed (two existing unused-expression warnings).
  • Seven affected documentation SDK tests passed.
  • Production install without httpx, httpcore, or sniffio: real sync/async HTTP, TLS rejection, custom CA, and SSL_NO_VERIFY checks passed at both 2.15.1 and 2.16.0. 100 async requests produced zero sniffio import attempts.
  • Minimum-dependency checks for Reflex/CLI could not resolve the existing SDK development-version constraint. The CLI check fails identically on unchanged base fc761bd0b.
  • Browser integration tests were not run. Independent migration review found no actionable defects.