3.19.0 (2026-06-01)
Added
SessionandAsyncSessionconstructors now acceptparams,cookies,proxies,verifyandcert
so that per-request defaults can be configured at initialization, consistently withheadersandauth. (#400)
Ease forward the migration from httpx for interested users.- A plain
http.cookiejar.CookieJar(or a mapping) provided ascookiesis now coerced into a
RequestsCookieJar. TheSession/AsyncSessionconstructor always coerces (sosession.cookies.set(...)
works), while at the request level an unknownCookieJarsubclass (e.g.MozillaCookieJaror any
file-backed/custom jar) is left untouched to preserve its behavior. (#401, #404) - Support for the alternative TLS backend BoringSSL via the
utlsextra.
Niquests now offer a first-class TLS browser impersonation without ever-changing your http client.
It is automatically done (e.g. negotiated) once the extra is installed. You will need to keep it
regularly updated so that you have the latest TLS specs of modern browsers. SessionandAsyncSessionconstructors now acceptallow_incoming_cookies(defaults toTrue).
Set it toFalseto ignore every cookie sent by the remote peer (viaSet-Cookie) so that nothing
is merged into the session jar, including cookies carried across redirect hops. Outgoing cookies you
set yourself are still emitted.Session.request/AsyncSession.request(and the verb shortcuts) now accept anoverride_scheme
keyword argument. When abase_urlis set on the Session, it override the scheme of the final
(merged) URL just before the adapter is picked, so you can target a different scheme (e.g.sse,
ws/wss, optionally with an implementation suffix likesse+unix) without retyping the full URL. (#325)
Changed
-
The
cookiesattribute ofSession,AsyncSessionandResponseis now always typed as
RequestsCookieJarinstead ofRequestsCookieJar | CookieJar. This restores the ergonomic mapping
interface (e.g.session.cookies.set(...)) when using static type checkers. (#401, #404)This is not a runtime breaking change: reading
.cookiesis unchanged, and a nativeCookieJar
is still accepted everywhere it is passed as an argument (it is coerced when relevant). We do,
however, acknowledge a static-typing trade-off: assigning a custom/non-RequestsCookieJarjar
directly to the attribute (e.g.session.cookies = MozillaCookieJar(...)) now makes type checkers
such as mypy complain, since the attribute is annotated asRequestsCookieJar. The assignment keeps
working at runtime; if you rely on it, add a# type: ignore. We chose narrowing on
purpose the predominant path is thatRequestsCookieJaris expected while subclasses (custom implementation)
are a niche usage. -
CaseInsensitiveDictis now generic over its key and value types (CaseInsensitiveDict[_KT, _VT],
mirroringdict/Mapping), andResponse.headers/Response.trailersare typed as
CaseInsensitiveDict[str, str]. Reading a response header (e.g.response.headers["Content-Type"])
now yieldsstrinstead ofstr | bytes, removing the need for acast/assertto use the headers
as a plain string mapping with static type checkers. (#401)This is purely a typing improvement with no runtime change: the class still subclasses
collections.abc.MutableMapping(it merely also gainstyping.Generic), so the Python 3.7 floor and
the existing behavior are preserved, and no new dependency is introduced. Unsubscripted
CaseInsensitiveDictkeeps its historicalstr | byteskey/value types, so existing annotations are
unaffected.