feat: replace httpx by httpx2 - #4974
Open
Kumzy wants to merge 7 commits into
Open
Conversation
`httpx2` is the Pydantic-maintained fork of `httpx` 0.28.1 with an identical public API. Switch the `testing` extra to `httpx2>=2.5` and rename the imports across `litestar/testing`. The SSE tests and the jwt header assertions move too: they stop type-checking the moment `subprocess_*_client` and `AsyncTestClient` become httpx2 types, and httpx2 2.10 narrowed `Headers.get` to `str | None`. `httpx` stays pinned in the dev group until `tools/` and the remaining direct users migrate.
`client.sse()` landed in httpx2 2.5 and covers what `httpx-sse` gave us, so drop the dependency.
Retires the temporary `httpx` pin from the dev group; `httpx`, `httpcore` and `httpx-sse` are no longer resolved at all.
Covers the test client base classes, the `httpx2` logger name, the `python-httpx2` User-Agent and the new dependency floors. The CSRF example in the middleware docs stays on `httpx`: it demonstrates calling a running server with your own client and offers `requests` as an equal alternative, so it should not track Litestar's test-client choice.
Kumzy
requested review from
a team,
JacobCoffee and
provinzkraut
as code owners
August 10, 2026 10:49
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4974 +/- ##
=======================================
Coverage 67.19% 67.19%
=======================================
Files 293 293
Lines 15363 15363
Branches 1745 1745
=======================================
Hits 10323 10323
Misses 4890 4890
Partials 150 150 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
This PR aim to replace
httpxfor thetestingextra byhttpx2library.As httpx is no longer maintained and won't receive any updates regarding future versions of Python, I suggest to change the library behind the TestClient for the 3.x release.
The API behind is mostly the same
📚 Documentation preview 📚: https://litestar-org.github.io/litestar-docs-preview/4974