httpcore2 2.13.1__tar.gz → 2.15.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.
Files changed (38) hide show
  1. {httpcore2-2.13.1 → httpcore2-2.15.0}/CHANGELOG.md +17 -0
  2. {httpcore2-2.13.1 → httpcore2-2.15.0}/PKG-INFO +19 -3
  3. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_async/http2.py +29 -6
  4. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_async/http_proxy.py +7 -3
  5. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_backends/anyio.py +1 -0
  6. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_sync/http2.py +29 -6
  7. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_sync/http_proxy.py +7 -3
  8. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_synchronization.py +25 -0
  9. {httpcore2-2.13.1 → httpcore2-2.15.0}/pyproject.toml +1 -2
  10. {httpcore2-2.13.1 → httpcore2-2.15.0}/.gitignore +0 -0
  11. {httpcore2-2.13.1 → httpcore2-2.15.0}/LICENSE.md +0 -0
  12. {httpcore2-2.13.1 → httpcore2-2.15.0}/README.md +0 -0
  13. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/__init__.py +0 -0
  14. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_api.py +0 -0
  15. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_async/__init__.py +0 -0
  16. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_async/connection.py +0 -0
  17. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_async/connection_pool.py +0 -0
  18. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_async/http11.py +0 -0
  19. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_async/interfaces.py +0 -0
  20. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_async/socks_proxy.py +0 -0
  21. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_backends/__init__.py +0 -0
  22. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_backends/auto.py +0 -0
  23. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_backends/base.py +0 -0
  24. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_backends/mock.py +0 -0
  25. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_backends/sync.py +0 -0
  26. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_backends/trio.py +0 -0
  27. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_exceptions.py +0 -0
  28. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_models.py +0 -0
  29. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_ssl.py +0 -0
  30. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_sync/__init__.py +0 -0
  31. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_sync/connection.py +0 -0
  32. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_sync/connection_pool.py +0 -0
  33. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_sync/http11.py +0 -0
  34. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_sync/interfaces.py +0 -0
  35. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_sync/socks_proxy.py +0 -0
  36. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_trace.py +0 -0
  37. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/_utils.py +0 -0
  38. {httpcore2-2.13.1 → httpcore2-2.15.0}/httpcore2/py.typed +0 -0
@@ -4,6 +4,23 @@ 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.15.0 (October 19th, 2026)
8
+
9
+ ### Removed
10
+
11
+ * Drop support for Python 3.10. ([#1274](https://github.com/pydantic/httpx2/pull/1274))
12
+
13
+ ## 2.14.0 (October 18th, 2026)
14
+
15
+ ### Fixed
16
+
17
+ * Keep `CONNECT` and absolute-form proxy targets when the request sets the `target` extension.
18
+ ([#1262](https://github.com/pydantic/httpx2/pull/1262))
19
+ * Stop blocking reads when an HTTP/2 server lowers `SETTINGS_MAX_CONCURRENT_STREAMS` while requests are in flight.
20
+ ([#1217](https://github.com/pydantic/httpx2/pull/1217))
21
+ * Raise `WriteError` instead of `anyio.EndOfStream` when writing after the peer closes a TLS connection without `close_notify`.
22
+ ([#1263](https://github.com/pydantic/httpx2/pull/1263))
23
+
7
24
  ## 2.13.1 (September 23rd, 2026)
8
25
 
9
26
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: httpcore2
3
- Version: 2.13.1
3
+ Version: 2.15.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
@@ -19,14 +19,13 @@ Classifier: License :: OSI Approved :: BSD License
19
19
  Classifier: Operating System :: OS Independent
20
20
  Classifier: Programming Language :: Python :: 3
21
21
  Classifier: Programming Language :: Python :: 3 :: Only
22
- Classifier: Programming Language :: Python :: 3.10
23
22
  Classifier: Programming Language :: Python :: 3.11
24
23
  Classifier: Programming Language :: Python :: 3.12
25
24
  Classifier: Programming Language :: Python :: 3.13
26
25
  Classifier: Programming Language :: Python :: 3.14
27
26
  Classifier: Programming Language :: Python :: 3.15
28
27
  Classifier: Topic :: Internet :: WWW/HTTP
29
- Requires-Python: >=3.10
28
+ Requires-Python: >=3.11
30
29
  Requires-Dist: h11>=0.16
31
30
  Requires-Dist: truststore>=0.10
32
31
  Provides-Extra: asyncio
@@ -152,6 +151,23 @@ All notable changes to this project will be documented in this file.
152
151
 
153
152
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
154
153
 
154
+ ## 2.15.0 (October 19th, 2026)
155
+
156
+ ### Removed
157
+
158
+ * Drop support for Python 3.10. ([#1274](https://github.com/pydantic/httpx2/pull/1274))
159
+
160
+ ## 2.14.0 (October 18th, 2026)
161
+
162
+ ### Fixed
163
+
164
+ * Keep `CONNECT` and absolute-form proxy targets when the request sets the `target` extension.
165
+ ([#1262](https://github.com/pydantic/httpx2/pull/1262))
166
+ * Stop blocking reads when an HTTP/2 server lowers `SETTINGS_MAX_CONCURRENT_STREAMS` while requests are in flight.
167
+ ([#1217](https://github.com/pydantic/httpx2/pull/1217))
168
+ * Raise `WriteError` instead of `anyio.EndOfStream` when writing after the peer closes a TLS connection without `close_notify`.
169
+ ([#1263](https://github.com/pydantic/httpx2/pull/1263))
170
+
155
171
  ## 2.13.1 (September 23rd, 2026)
156
172
 
157
173
  ### 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
- await self._max_streams_semaphore.acquire()
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
- await self._max_streams_semaphore.release()
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
- await self._max_streams_semaphore.acquire()
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
- await self._max_streams_semaphore.release()
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
- events: list[h2.events.Event] = self._h2_state.receive_data(data)
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={key: value for key, value in request.extensions.items() if key != "sni_hostname"},
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={key: value for key, value in request.extensions.items() if key != "sni_hostname"},
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
 
@@ -46,6 +46,7 @@ class AnyIOStream(AsyncNetworkStream):
46
46
  TimeoutError: WriteTimeout,
47
47
  anyio.BrokenResourceError: WriteError,
48
48
  anyio.ClosedResourceError: WriteError,
49
+ anyio.EndOfStream: WriteError,
49
50
  }
50
51
  with map_exceptions(exc_map):
51
52
  with anyio.fail_after(timeout):
@@ -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
- self._max_streams_semaphore.acquire()
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._max_streams_semaphore.release()
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.acquire()
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._max_streams_semaphore.release()
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
- events: list[h2.events.Event] = self._h2_state.receive_data(data)
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={key: value for key, value in request.extensions.items() if key != "sni_hostname"},
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={key: value for key, value in request.extensions.items() if key != "sni_hostname"},
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
 
@@ -20,7 +20,7 @@ name = "httpcore2"
20
20
  dynamic = ["readme", "version"]
21
21
  description = "A minimal low-level HTTP client."
22
22
  license = "BSD-3-Clause"
23
- requires-python = ">=3.10"
23
+ requires-python = ">=3.11"
24
24
  authors = [{ name = "Tom Christie", email = "tom@tomchristie.com" }]
25
25
  maintainers = [
26
26
  { name = "Pydantic Services Inc.", email = "engineering@pydantic.dev" },
@@ -36,7 +36,6 @@ classifiers = [
36
36
  "Operating System :: OS Independent",
37
37
  "Programming Language :: Python :: 3",
38
38
  "Programming Language :: Python :: 3 :: Only",
39
- "Programming Language :: Python :: 3.10",
40
39
  "Programming Language :: Python :: 3.11",
41
40
  "Programming Language :: Python :: 3.12",
42
41
  "Programming Language :: Python :: 3.13",
File without changes
File without changes
File without changes
File without changes
File without changes