Repository navigation
feat: implement HTTPX drop-in Phase 1 production semantics - #5
Merged
Merged
Conversation
- 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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Timeout::compat()— HTTPX-compatible 5s all phases including totalTimeout::native()— eggfetch 30s per-phase, no totalTimeoutto support HTTPX per-phase keyword args:Timeout(pool=2.0, connect=5.0, read=30.0, total=60.0)Track C: Resource limits
Limitsmodel in eggfetch-core withLimits::compat()andLimits::native()constructorsLimitsintoClientBuildervia.limits()methodLimitsin Python with HTTPX-compatible defaults (100 max connections, 20 keep-alive, 5s expiry)Track F: Environment trust
trust_envparameter to PythonClientandAsyncClientconstructorstrust_env=True(default), readsHTTP_PROXY,HTTPS_PROXY,ALL_PROXY,NO_PROXYenv varsPROXY-ENV-001in allowed-differences.toml fromrequired-latertoresolvedDocumentation
Verification
Note: Python crate cannot build locally due to pyo3-ffi/Python 3.14 incompatibility, but the Rust changes compile cleanly.