Skip to content

feat: implement HTTPX drop-in Phase 1 production semantics - #5

Merged
dbowm91 merged 5 commits into
mainfrom
feat/httpx-phase1-production-semantics
Jul 22, 2026
Merged

dbowm91 merged 5 commits into
mainfrom
feat/httpx-phase1-production-semantics

Conversation

@dbowm91

@dbowm91 dbowm91 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Implements Track B (timeout defaults), Track C (resource limits), and Track F (environment trust) from the HTTPX drop-in Phase 1 plan.

Changes

Track B: Timeout defaults

  • Added Timeout::compat() — HTTPX-compatible 5s all phases including total
  • Added Timeout::native() — eggfetch 30s per-phase, no total
  • Updated Python Timeout to support HTTPX per-phase keyword args: Timeout(pool=2.0, connect=5.0, read=30.0, total=60.0)

Track C: Resource limits

  • Added Limits model in eggfetch-core with Limits::compat() and Limits::native() constructors
  • Wired Limits into ClientBuilder via .limits() method
  • Exposed Limits in Python with HTTPX-compatible defaults (100 max connections, 20 keep-alive, 5s expiry)

Track F: Environment trust

  • Added trust_env parameter to Python Client and AsyncClient constructors
  • When trust_env=True (default), reads HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY env vars
  • Updated PROXY-ENV-001 in allowed-differences.toml from required-later to resolved

Documentation

  • Updated README.md, concepts/timeouts.md, concepts/pooling.md, python/guide.md

Verification

  • 764 Rust tests pass
  • Feature matrix (no-default, http1+tls-rustls, all-features) compiles clean
  • Clippy clean (non-Python crates)
  • Formatting clean

Note: Python crate cannot build locally due to pyo3-ffi/Python 3.14 incompatibility, but the Rust changes compile cleanly.

dbowm91 added 5 commits July 21, 2026 22:26
- Add Timeout::compat() and Timeout::native() named constructors
  - compat(): HTTPX-compatible 5s all phases including total
  - native(): eggfetch 30s per-phase, no total
- Add Limits model for HTTPX-compatible resource limits
  - Limits::compat(): 100 max connections, 20 keep-alive, 5s expiry
  - Limits::native(): unlimited defaults
  - Wired into ClientBuilder via .limits() method
- Add trust_env parameter to Python Client and AsyncClient
  - Reads HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY env vars
  - Default true; set false to disable env var discovery
- Enhance Python Timeout to support HTTPX per-phase keyword args
  - Timeout(pool=2.0, connect=5.0, read=30.0, total=60.0)
- Update PROXY-ENV-001 in allowed-differences.toml to resolved
- Update docs: README, concepts/timeouts, concepts/pooling, python/guide

Track B (timeout defaults), Track C (resource limits), and
Track F (environment trust) from the Phase 1 plan.
…fecycle), Track B2 (timeout validation)

Track A — Connect deadline enforcement:
- Add ConnectTimeout<C> wrapper around hyper connector that enforces
  DNS/TCP/TLS deadline via tokio::time::timeout
- Update ClientInner to use TimeoutHyperClient type
- Update builder to wrap connector with ConnectTimeout when timeout.connect is set
- Update transport/direct.rs to use TimeoutHyperClient
- Document connect timeout enforcement in timeout.rs and docs

Track D — Deterministic client lifecycle:
- Refactor PyClient: client field is now Option<Client>, close() drops
  the core client and shuts down the tokio runtime
- Refactor PyAsyncClient: client field is now Option<Client>, close()
  drops the core client reference
- Both clients now properly release resources when closed
- Added ensure_client() helper for safe access

Track B2 — Remove indefinite accidental behavior:
- Python timeout validation now rejects zero values (v <= 0.0)
- Added zero_duration_timeout_is_valid test in Rust

All 768 tests pass. Clippy clean. Formatting clean.
- Refactor PyClient: client field is now Mutex<Option<Client>>
- All request methods changed from &mut self to &self
- close() and is_closed() use Mutex for thread-safe state access
- Multiple Python threads can now call request methods concurrently
  on the same Client instance (PyO3 serializes via Mutex)
- Added clone_client() helper for safe Arc extraction from Mutex
- Updated __exit__ and __repr__ to use Mutex

E2 (async concurrency) already works via &self + Arc cloning.
E3 (fork behavior) deferred to later milestone.

All 768 tests pass. Clippy clean. Formatting clean.
- Extract duplicated env var reading into shared helpers in proxy.rs:
  env_proxy_url() reads HTTP_PROXY/http_proxy/HTTPS_PROXY/https_proxy/
  ALL_PROXY/all_proxy in priority order
  env_no_proxy_url() reads NO_PROXY/no_proxy
- Both client.rs and async_client.rs now use the shared helpers
- NO_PROXY infrastructure is now available for future wiring
- Deduplicated identical env var reading code blocks

All 768 tests pass. Clippy clean. Formatting clean.
…nterpreter shutdown, resource stabilization, soak tests, status file
@dbowm91
dbowm91 merged commit ec60526 into main Jul 22, 2026
13 of 33 checks passed
@dbowm91
dbowm91 deleted the feat/httpx-phase1-production-semantics branch July 22, 2026 03:50
dbowm91 pushed a commit that referenced this pull request Aug 26, 2026
Core:
- retry: default backoff factor 0.5 -> 2.0 so delays grow between
  retries; docs aligned (audit #2)
- proxy: CONNECT target brackets IPv6 literals in authority-form (#3)
- proxy: effective_timeout() now measures remaining budget with a fresh
  Instant per phase, enforcing one monotonic request deadline across
  multi-phase proxy setup instead of a stale snapshot (#4)
- proxy: reject truncated status/header lines on EOF (#14); header-count
  limit checked before push, admitting exactly MAX (#19)
- pipeline: redirect drain uses the byte-bounded helper under the total
  deadline (no full-body buffering) and gains a time cap when no total
  is set; applies to the retry-path drain too (#10)
- pool: closed per-origin semaphore no longer bypasses both limits; the
  request stays bounded by the global permit (#18)
- http3: sender cache uses per-origin OnceCell cells so concurrent
  requests share one QUIC connection instead of racing get-then-insert
  and orphaning driver tasks (#15)

FFI:
- streaming: cancel/free publish on a watch channel that a parked next
  selects on, so a blocked reader wakes immediately even on idle streams
  (#5); allocation/poison failures set last_error before returning null
  (#11); state is Arc-shared so free during a parked next is safe (#12);
  next routes through runtime-aware blocking_send

Python bindings:
- network_stream: sync read/write acquire the OS mutex inside
  allow_threads so a contended lock never stalls other Python threads
  while holding the GIL (#9)

Compat facade (httpx):
- URL: schemeless inputs are kept as relative references instead of
  being prefixed with a fabricated http:// authority; join() performs
  RFC 3986 resolution; _redirect_url resolves Location via urljoin so
  relative (./b, ../baz) and protocol-relative (//host) redirects
  dispatch to the correct host (#1, #6, #7)
- Headers: get()/[] comma-join duplicate values like HTTPX (#8)
- Response: iter_bytes/aiter_bytes raise StreamClosed after close,
  matching iter_raw (#16)
- auth: callables returning neither Request nor iterable raise
  TypeError instead of silently sending unauthenticated requests (#17)

CLI:
- --file implies POST like curl -F (#13)
- NDJSON mode drops the embedded history array; hops are emitted once
  as their own records (#20)
- --retry-delay pins backoff factor to 1 for flat inter-retry delay

Tests updated/added for each behavior change. Note: this changes the
executable SHA, so the exact-SHA compat qualification ledger requires
restarting its freeze step per plans/httpx-parity-correction-status.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant