Releases: jawah/niquests
Version 3.3.2
3.3.2 (2023-11-19)
Fixed
- Hooks that do not accept keyword arguments are rejected.
- Applying
max_fetch
toSession.gather(...)
did not prevent the adapter from draining all pending responses. - Closed session having unconsumed multiplexed requests leaked an exception from urllib3.future.
Changed
- Aligned
qh3
version constraint inhttp3
extra with urllib3.future.
Version 3.3.1
3.3.1 (2023-11-18)
Fixed
- Warning filter (ignore) for
DependencyWarning
within urllib3.future wasn't applied in time.
Version 3.3.0
3.3.0 (2023-11-18)
Added
- Maximum of (lazy) response(s) to be resolved when calling
Session.gather(..., max_fetch = ...)
. Specifying a valid int tomax_fetch
will stop after resolving the right amount of responses.
Changed
- urllib3.future minimal version raised to 2.3.900 to leverage the fallback top-level package
urllib3_future
.
Fixed
- Runtime error when accidentally overriding
urllib3.future
by an external dependency. - Undesirable warning yielded by
cryptography
because of a Microsoft root certificate. "Parsed a negative serial number, which is disallowed by RFC 5280." - Consider newly registered custom CA when using
wassima.register_ca(...)
.
Removed
- Dependency check at runtime for
urllib3
. There are no more checks and warnings at runtime for that subject. Ever.
Version 3.2.4
3.2.4 (2023-11-15)
Fixed
- Compatibility with some third-party mock tools.
Changed
- Relax IllegalHeader constraint when the value is an integer, or float.
Version 3.2.3
3.2.3 (2023-11-11)
Fixed
- Overall performance improvement.
- A racing condition in
HTTPAdapter
with multiplexed enabled while in threads.
Removed
- Checks for header validity as it is duplicated (upstream does it already).
Warning: Functioncheck_header_validity
has been removed. It was not public in the first place.
Changed
- Cached proxies from environment to avoid unnecessary scans on each request.
Version 3.2.2
3.2.2 (2023-11-08)
Changed
- Enforced a maximum in-flight request when using multiplexed connections. Default to 124 per connection
so, actually 1240 per Session (default is 10 connections). This can be overridden in ourHTTPAdapter
for advanced users.
This limit was changed due to a constraint inqh3
, for now, we have no way to set this dynamically. We choose the safest
lowest value in h2, and qh3. This will be improved later.
Fixed
- Performance issue in
get_environ_proxies()
.
Version 3.2.1
3.2.1 (2023-11-06)
Fixed
- Performance issues in HTTP/2, and HTTP/3, with or without multiplexed connections.
Changed
- Enforced a maximum in-flight request when using multiplexed connections. Default to 200 per connection
so, actually 2000 per Session (default is 10 connections). This can be overridden in ourHTTPAdapter
for advanced users.
Version 3.2.0
3.2.0 (2023-11-05)
Changed
- Changed method
raise_for_status
in classResponse
to return self in order to make the call chainable.
Idea taken from upstream psf#6215 - Bump minimal version supported for
urllib3.future
to 2.2.901 for recently introduced added features (bellow).
Added
-
Support for multiplexed connection in HTTP/2 and HTTP/3. Concurrent requests per connection are now a thing, in synchronous code.
This feature is the real advantage of using binaries HTTP protocols.
It is disabled by default and can be enabled throughSession(multiplexed=True)
, eachResponse
object will
be 'lazy' loaded. Accessing anything from the returnedResponse
will block the code until the target response is retrieved.
UseSession.gather()
to efficiently receive responses. You may also give a list of responses that you want to load.Example A) Emitting concurrent requests and loading them via
Session.gather()
from niquests import Session from time import time s = Session(multiplexed=True) before = time() responses = [] responses.append( s.get("https://pie.dev/delay/3") ) responses.append( s.get("https://pie.dev/delay/1") ) s.gather() print(f"waited {time() - before} second(s)") # will print 3s
Example B) Emitting concurrent requests and loading them via direct access
from niquests import Session from time import time s = Session(multiplexed=True) before = time() responses = [] responses.append( s.get("https://pie.dev/delay/3") ) responses.append( s.get("https://pie.dev/delay/1") ) # internally call gather with self (Response) print(responses[0].status_code) # 200! :! Hidden call to s.gather(responses[0]) print(responses[1].status_code) # 200! print(f"waited {time() - before} second(s)") # will print 3s
You have nothing to do, everything from streams to connection pooling are handled automagically!
-
Support for in-memory intermediary/client certificate (mTLS).
Thanks for support withinurllib3.future
. Unfortunately, this feature may not be available depending on your platform.
Passingcert=(a, b, c)
where a or/and b contains directly the certificate is supported.
See https://urllib3future.readthedocs.io/en/latest/advanced-usage.html#in-memory-client-mtls-certificate for more information.
It is proposed to circumvent the recent pyOpenSSL complete removal. -
Detect if a new (stable) version is available when invoking
python -m niquests.help
and propose it for installation. -
Add the possibility to disable a specific protocol (e.g. HTTP/2, and/or HTTP/3) when constructing
Session
.
Like so:s = Session(disable_http2=..., disable_http3=...)
both options are set toFalse
, thus letting them be enabled.
urllib3.future does not permit to disable HTTP/1.1 for now. -
Support passing a single
str
toauth=...
in addition to actually supported types. It will be treated as a
Bearer token, by default to theAuthorization
header. It's a shortcut. You may keep your own token prefix in a given
string (e.g. if not Bearer). -
Added
MultiplexingError
exception for anything related to failure with a multiplexed connection. -
Added async support through
AsyncSession
that utilizes an underlying thread pool.from niquests import AsyncSession import asyncio from time import time async def emit() -> None: responses = [] async with AsyncSession(multiplexed=True) as s: responses.append(await s.get("https://pie.dev/get")) responses.append(await s.get("https://pie.dev/head")) await s.gather() print(responses) async def main() -> None: foo = asyncio.create_task(emit()) bar = asyncio.create_task(emit()) await foo await bar if __name__ == "__main__": before = time() asyncio.run(main()) print(time() - before)
Or without
multiplexing
if you want to keep multiple connections open per host per request.from niquests import AsyncSession import asyncio from time import time async def emit() -> None: responses = [] async with AsyncSession() as s: responses.append(await s.get("https://pie.dev/get")) responses.append(await s.get("https://pie.dev/head")) print(responses) async def main() -> None: foo = asyncio.create_task(emit()) bar = asyncio.create_task(emit()) await foo await bar if __name__ == "__main__": before = time() asyncio.run(main()) print(time() - before)
You may disable concurrent threads by setting
AsyncSession.no_thread = True
.
Security
- Certificate revocation verification may not be fired for subsequent requests in a specific condition (redirection).
Version 3.1.4
3.1.4 (2023-10-23)
Fixed
- Static type checker not accepting iterable[str] for data. A fix in urllib3.future allows it since v2.1.902.
- Unattended override of manually provided Authorization if
.netrc
existed with an eligible entry.
Taken from closed PR psf#6555 and initially raised in psf#3929
Added
- oheaders property in
Request
, andPreparedRequest
in addition toResponse
.
Version 3.1.3
3.1.3 (2023-10-19)
Fixed
- oheaders from a Response contains
Set-Cookie
entries when it should not. - Static type checker not accepting list[str] in values for argument param.
- Static type checker not accepting Iterable[bytes] for data.
- Function proxy_bypass_registry for Windows may be fooled by insufficient control on our end.
Patch taken from idle upstream PR psf#6302 - SSLError message related to the certificate revocation could print
None
instead ofunspecified
for the reason.
Changed
- Allow setting
None
in max_size for SharableLimitedDict to remove limits. - Using
RLock
instead ofLock
in SharableLimitedDict, and InMemoryRevocationStatus classes.
Misc
- Missing assert statements for test test_header_validation.
- Unrelated warnings are now silent in our test suite.
- Unexpected warning now trigger an error in our test suite.
- Removed
tests.compat
. - Removed
test-readme
,flake8
, andpublish
from Makefile.
Added
- Extra-dist install
http3
to force install HTTP/3 support in your environment if not present. - Extra-dist install
ocsp
to force install certificate revocation support in your environment if not present.