httpcore2 2.13.1__tar.gz → 2.14.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {httpcore2-2.13.1 → httpcore2-2.14.0}/CHANGELOG.md +11 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/PKG-INFO +12 -1
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_async/http2.py +29 -6
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_async/http_proxy.py +7 -3
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_backends/anyio.py +1 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_sync/http2.py +29 -6
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_sync/http_proxy.py +7 -3
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_synchronization.py +25 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/.gitignore +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/LICENSE.md +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/README.md +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/__init__.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_api.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_async/__init__.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_async/connection.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_async/connection_pool.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_async/http11.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_async/interfaces.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_async/socks_proxy.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_backends/__init__.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_backends/auto.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_backends/base.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_backends/mock.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_backends/sync.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_backends/trio.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_exceptions.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_models.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_ssl.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_sync/__init__.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_sync/connection.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_sync/connection_pool.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_sync/http11.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_sync/interfaces.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_sync/socks_proxy.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_trace.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/_utils.py +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/httpcore2/py.typed +0 -0
- {httpcore2-2.13.1 → httpcore2-2.14.0}/pyproject.toml +0 -0
|
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
6
6
|
|
|
7
|
+
## 2.14.0 (October 18th, 2026)
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
* Keep `CONNECT` and absolute-form proxy targets when the request sets the `target` extension.
|
|
12
|
+
([#1262](https://github.com/pydantic/httpx2/pull/1262))
|
|
13
|
+
* Stop blocking reads when an HTTP/2 server lowers `SETTINGS_MAX_CONCURRENT_STREAMS` while requests are in flight.
|
|
14
|
+
([#1217](https://github.com/pydantic/httpx2/pull/1217))
|
|
15
|
+
* Raise `WriteError` instead of `anyio.EndOfStream` when writing after the peer closes a TLS connection without `close_notify`.
|
|
16
|
+
([#1263](https://github.com/pydantic/httpx2/pull/1263))
|
|
17
|
+
|
|
7
18
|
## 2.13.1 (September 23rd, 2026)
|
|
8
19
|
|
|
9
20
|
### Fixed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: httpcore2
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.14.0
|
|
4
4
|
Summary: A minimal low-level HTTP client.
|
|
5
5
|
Project-URL: Changelog, https://github.com/pydantic/httpx2/blob/main/src/httpcore2/CHANGELOG.md
|
|
6
6
|
Project-URL: Homepage, https://github.com/pydantic/httpx2
|
|
@@ -152,6 +152,17 @@ All notable changes to this project will be documented in this file.
|
|
|
152
152
|
|
|
153
153
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
154
154
|
|
|
155
|
+
## 2.14.0 (October 18th, 2026)
|
|
156
|
+
|
|
157
|
+
### Fixed
|
|
158
|
+
|
|
159
|
+
* Keep `CONNECT` and absolute-form proxy targets when the request sets the `target` extension.
|
|
160
|
+
([#1262](https://github.com/pydantic/httpx2/pull/1262))
|
|
161
|
+
* Stop blocking reads when an HTTP/2 server lowers `SETTINGS_MAX_CONCURRENT_STREAMS` while requests are in flight.
|
|
162
|
+
([#1217](https://github.com/pydantic/httpx2/pull/1217))
|
|
163
|
+
* Raise `WriteError` instead of `anyio.EndOfStream` when writing after the peer closes a TLS connection without `close_notify`.
|
|
164
|
+
([#1263](https://github.com/pydantic/httpx2/pull/1263))
|
|
165
|
+
|
|
155
166
|
## 2.13.1 (September 23rd, 2026)
|
|
156
167
|
|
|
157
168
|
### Fixed
|
|
@@ -105,13 +105,23 @@ class AsyncHTTP2Connection(AsyncConnectionInterface):
|
|
|
105
105
|
# its max_concurrent_streams value
|
|
106
106
|
self._max_streams = 1
|
|
107
107
|
|
|
108
|
+
# Revoked permits still held by active or queued requests.
|
|
109
|
+
self._max_streams_deficit = 0
|
|
110
|
+
|
|
108
111
|
local_settings_max_streams = self._h2_state.local_settings.max_concurrent_streams
|
|
109
112
|
self._max_streams_semaphore = AsyncSemaphore(local_settings_max_streams)
|
|
110
113
|
|
|
111
114
|
for _ in range(local_settings_max_streams - self._max_streams):
|
|
112
115
|
await self._max_streams_semaphore.acquire()
|
|
113
116
|
|
|
114
|
-
|
|
117
|
+
# A queued request may receive a permit just before the limit drops.
|
|
118
|
+
while True:
|
|
119
|
+
await self._max_streams_semaphore.acquire()
|
|
120
|
+
with AsyncShieldCancellation():
|
|
121
|
+
async with self._state_lock:
|
|
122
|
+
if not self._max_streams_deficit:
|
|
123
|
+
break
|
|
124
|
+
self._max_streams_deficit -= 1
|
|
115
125
|
|
|
116
126
|
try:
|
|
117
127
|
stream_id = self._h2_state.get_next_available_stream_id()
|
|
@@ -338,7 +348,6 @@ class AsyncHTTP2Connection(AsyncConnectionInterface):
|
|
|
338
348
|
for event in events:
|
|
339
349
|
if isinstance(event, h2.events.RemoteSettingsChanged):
|
|
340
350
|
async with Trace("receive_remote_settings", logger, request) as trace:
|
|
341
|
-
await self._receive_remote_settings_change(event)
|
|
342
351
|
trace.return_value = event
|
|
343
352
|
|
|
344
353
|
elif isinstance(
|
|
@@ -366,17 +375,25 @@ class AsyncHTTP2Connection(AsyncConnectionInterface):
|
|
|
366
375
|
self._h2_state.local_settings.max_concurrent_streams,
|
|
367
376
|
)
|
|
368
377
|
if new_max_streams and new_max_streams != self._max_streams:
|
|
378
|
+
# Never wait for permits while holding the read lock.
|
|
369
379
|
while new_max_streams > self._max_streams:
|
|
370
|
-
|
|
380
|
+
if self._max_streams_deficit > 0:
|
|
381
|
+
self._max_streams_deficit -= 1
|
|
382
|
+
else:
|
|
383
|
+
await self._max_streams_semaphore.release()
|
|
371
384
|
self._max_streams += 1
|
|
372
385
|
while new_max_streams < self._max_streams:
|
|
373
|
-
|
|
386
|
+
if not self._max_streams_semaphore.acquire_if_available():
|
|
387
|
+
self._max_streams_deficit += 1
|
|
374
388
|
self._max_streams -= 1
|
|
375
389
|
|
|
376
390
|
async def _response_closed(self, stream_id: int) -> None:
|
|
377
391
|
async with self._state_lock:
|
|
378
392
|
if stream_id in self._events:
|
|
379
|
-
|
|
393
|
+
if self._max_streams_deficit > 0:
|
|
394
|
+
self._max_streams_deficit -= 1
|
|
395
|
+
else:
|
|
396
|
+
await self._max_streams_semaphore.release()
|
|
380
397
|
del self._events[stream_id]
|
|
381
398
|
if self._connection_terminated and not self._events:
|
|
382
399
|
await self.aclose()
|
|
@@ -422,7 +439,13 @@ class AsyncHTTP2Connection(AsyncConnectionInterface):
|
|
|
422
439
|
self._connection_error = True
|
|
423
440
|
raise exc
|
|
424
441
|
|
|
425
|
-
|
|
442
|
+
# Apply settings and stream admission limits atomically.
|
|
443
|
+
with AsyncShieldCancellation():
|
|
444
|
+
async with self._state_lock:
|
|
445
|
+
events: list[h2.events.Event] = self._h2_state.receive_data(data)
|
|
446
|
+
for event in events:
|
|
447
|
+
if isinstance(event, h2.events.RemoteSettingsChanged):
|
|
448
|
+
await self._receive_remote_settings_change(event)
|
|
426
449
|
|
|
427
450
|
return events
|
|
428
451
|
|
|
@@ -184,14 +184,16 @@ class AsyncForwardHTTPConnection(AsyncConnectionInterface):
|
|
|
184
184
|
scheme=self._proxy_origin.scheme,
|
|
185
185
|
host=self._proxy_origin.host,
|
|
186
186
|
port=self._proxy_origin.port,
|
|
187
|
-
target=bytes(request.url),
|
|
187
|
+
target=bytes(request.url) if request.url.target.startswith(b"/") else request.url.target,
|
|
188
188
|
)
|
|
189
189
|
proxy_request = Request(
|
|
190
190
|
method=request.method,
|
|
191
191
|
url=url,
|
|
192
192
|
headers=headers,
|
|
193
193
|
content=request.stream,
|
|
194
|
-
extensions={
|
|
194
|
+
extensions={
|
|
195
|
+
key: value for key, value in request.extensions.items() if key not in ("sni_hostname", "target")
|
|
196
|
+
},
|
|
195
197
|
)
|
|
196
198
|
return await self._connection.handle_async_request(proxy_request)
|
|
197
199
|
|
|
@@ -274,7 +276,9 @@ class AsyncTunnelHTTPConnection(AsyncConnectionInterface):
|
|
|
274
276
|
method=b"CONNECT",
|
|
275
277
|
url=connect_url,
|
|
276
278
|
headers=connect_headers,
|
|
277
|
-
extensions={
|
|
279
|
+
extensions={
|
|
280
|
+
key: value for key, value in request.extensions.items() if key not in ("sni_hostname", "target")
|
|
281
|
+
},
|
|
278
282
|
)
|
|
279
283
|
connect_response = await self._connection.handle_async_request(connect_request)
|
|
280
284
|
|
|
@@ -105,13 +105,23 @@ class HTTP2Connection(ConnectionInterface):
|
|
|
105
105
|
# its max_concurrent_streams value
|
|
106
106
|
self._max_streams = 1
|
|
107
107
|
|
|
108
|
+
# Revoked permits still held by active or queued requests.
|
|
109
|
+
self._max_streams_deficit = 0
|
|
110
|
+
|
|
108
111
|
local_settings_max_streams = self._h2_state.local_settings.max_concurrent_streams
|
|
109
112
|
self._max_streams_semaphore = Semaphore(local_settings_max_streams)
|
|
110
113
|
|
|
111
114
|
for _ in range(local_settings_max_streams - self._max_streams):
|
|
112
115
|
self._max_streams_semaphore.acquire()
|
|
113
116
|
|
|
114
|
-
|
|
117
|
+
# A queued request may receive a permit just before the limit drops.
|
|
118
|
+
while True:
|
|
119
|
+
self._max_streams_semaphore.acquire()
|
|
120
|
+
with ShieldCancellation():
|
|
121
|
+
with self._state_lock:
|
|
122
|
+
if not self._max_streams_deficit:
|
|
123
|
+
break
|
|
124
|
+
self._max_streams_deficit -= 1
|
|
115
125
|
|
|
116
126
|
try:
|
|
117
127
|
stream_id = self._h2_state.get_next_available_stream_id()
|
|
@@ -338,7 +348,6 @@ class HTTP2Connection(ConnectionInterface):
|
|
|
338
348
|
for event in events:
|
|
339
349
|
if isinstance(event, h2.events.RemoteSettingsChanged):
|
|
340
350
|
with Trace("receive_remote_settings", logger, request) as trace:
|
|
341
|
-
self._receive_remote_settings_change(event)
|
|
342
351
|
trace.return_value = event
|
|
343
352
|
|
|
344
353
|
elif isinstance(
|
|
@@ -366,17 +375,25 @@ class HTTP2Connection(ConnectionInterface):
|
|
|
366
375
|
self._h2_state.local_settings.max_concurrent_streams,
|
|
367
376
|
)
|
|
368
377
|
if new_max_streams and new_max_streams != self._max_streams:
|
|
378
|
+
# Never wait for permits while holding the read lock.
|
|
369
379
|
while new_max_streams > self._max_streams:
|
|
370
|
-
self.
|
|
380
|
+
if self._max_streams_deficit > 0:
|
|
381
|
+
self._max_streams_deficit -= 1
|
|
382
|
+
else:
|
|
383
|
+
self._max_streams_semaphore.release()
|
|
371
384
|
self._max_streams += 1
|
|
372
385
|
while new_max_streams < self._max_streams:
|
|
373
|
-
self._max_streams_semaphore.
|
|
386
|
+
if not self._max_streams_semaphore.acquire_if_available():
|
|
387
|
+
self._max_streams_deficit += 1
|
|
374
388
|
self._max_streams -= 1
|
|
375
389
|
|
|
376
390
|
def _response_closed(self, stream_id: int) -> None:
|
|
377
391
|
with self._state_lock:
|
|
378
392
|
if stream_id in self._events:
|
|
379
|
-
self.
|
|
393
|
+
if self._max_streams_deficit > 0:
|
|
394
|
+
self._max_streams_deficit -= 1
|
|
395
|
+
else:
|
|
396
|
+
self._max_streams_semaphore.release()
|
|
380
397
|
del self._events[stream_id]
|
|
381
398
|
if self._connection_terminated and not self._events:
|
|
382
399
|
self.close()
|
|
@@ -422,7 +439,13 @@ class HTTP2Connection(ConnectionInterface):
|
|
|
422
439
|
self._connection_error = True
|
|
423
440
|
raise exc
|
|
424
441
|
|
|
425
|
-
|
|
442
|
+
# Apply settings and stream admission limits atomically.
|
|
443
|
+
with ShieldCancellation():
|
|
444
|
+
with self._state_lock:
|
|
445
|
+
events: list[h2.events.Event] = self._h2_state.receive_data(data)
|
|
446
|
+
for event in events:
|
|
447
|
+
if isinstance(event, h2.events.RemoteSettingsChanged):
|
|
448
|
+
self._receive_remote_settings_change(event)
|
|
426
449
|
|
|
427
450
|
return events
|
|
428
451
|
|
|
@@ -184,14 +184,16 @@ class ForwardHTTPConnection(ConnectionInterface):
|
|
|
184
184
|
scheme=self._proxy_origin.scheme,
|
|
185
185
|
host=self._proxy_origin.host,
|
|
186
186
|
port=self._proxy_origin.port,
|
|
187
|
-
target=bytes(request.url),
|
|
187
|
+
target=bytes(request.url) if request.url.target.startswith(b"/") else request.url.target,
|
|
188
188
|
)
|
|
189
189
|
proxy_request = Request(
|
|
190
190
|
method=request.method,
|
|
191
191
|
url=url,
|
|
192
192
|
headers=headers,
|
|
193
193
|
content=request.stream,
|
|
194
|
-
extensions={
|
|
194
|
+
extensions={
|
|
195
|
+
key: value for key, value in request.extensions.items() if key not in ("sni_hostname", "target")
|
|
196
|
+
},
|
|
195
197
|
)
|
|
196
198
|
return self._connection.handle_request(proxy_request)
|
|
197
199
|
|
|
@@ -274,7 +276,9 @@ class TunnelHTTPConnection(ConnectionInterface):
|
|
|
274
276
|
method=b"CONNECT",
|
|
275
277
|
url=connect_url,
|
|
276
278
|
headers=connect_headers,
|
|
277
|
-
extensions={
|
|
279
|
+
extensions={
|
|
280
|
+
key: value for key, value in request.extensions.items() if key not in ("sni_hostname", "target")
|
|
281
|
+
},
|
|
278
282
|
)
|
|
279
283
|
connect_response = self._connection.handle_request(connect_request)
|
|
280
284
|
|
|
@@ -175,6 +175,28 @@ class AsyncSemaphore:
|
|
|
175
175
|
elif self._backend == "asyncio":
|
|
176
176
|
await self._anyio_semaphore.acquire()
|
|
177
177
|
|
|
178
|
+
def acquire_if_available(self) -> bool:
|
|
179
|
+
"""
|
|
180
|
+
Acquire a permit if one is immediately available, without blocking.
|
|
181
|
+
Returns True if a permit was acquired.
|
|
182
|
+
|
|
183
|
+
Like `release()`, this requires `setup()` to have run, which any
|
|
184
|
+
prior `acquire()` call ensures.
|
|
185
|
+
"""
|
|
186
|
+
if self._backend == "trio":
|
|
187
|
+
try:
|
|
188
|
+
self._trio_semaphore.acquire_nowait()
|
|
189
|
+
except trio.WouldBlock:
|
|
190
|
+
return False
|
|
191
|
+
return True
|
|
192
|
+
elif self._backend == "asyncio":
|
|
193
|
+
try:
|
|
194
|
+
self._anyio_semaphore.acquire_nowait()
|
|
195
|
+
except anyio.WouldBlock:
|
|
196
|
+
return False
|
|
197
|
+
return True
|
|
198
|
+
return False # pragma: no cover
|
|
199
|
+
|
|
178
200
|
async def release(self) -> None:
|
|
179
201
|
if self._backend == "trio":
|
|
180
202
|
self._trio_semaphore.release()
|
|
@@ -293,6 +315,9 @@ class Semaphore:
|
|
|
293
315
|
def acquire(self) -> None:
|
|
294
316
|
self._semaphore.acquire()
|
|
295
317
|
|
|
318
|
+
def acquire_if_available(self) -> bool:
|
|
319
|
+
return self._semaphore.acquire(blocking=False)
|
|
320
|
+
|
|
296
321
|
def release(self) -> None:
|
|
297
322
|
self._semaphore.release()
|
|
298
323
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|