httpcore2 2.12.0__tar.gz → 2.13.1__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.12.0 → httpcore2-2.13.1}/CHANGELOG.md +21 -0
  2. {httpcore2-2.12.0 → httpcore2-2.13.1}/PKG-INFO +23 -2
  3. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_async/connection.py +1 -1
  4. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_async/http_proxy.py +5 -4
  5. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_async/socks_proxy.py +3 -1
  6. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_sync/connection.py +1 -1
  7. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_sync/http_proxy.py +5 -4
  8. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_sync/socks_proxy.py +3 -1
  9. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_utils.py +7 -11
  10. {httpcore2-2.12.0 → httpcore2-2.13.1}/pyproject.toml +2 -2
  11. {httpcore2-2.12.0 → httpcore2-2.13.1}/.gitignore +0 -0
  12. {httpcore2-2.12.0 → httpcore2-2.13.1}/LICENSE.md +0 -0
  13. {httpcore2-2.12.0 → httpcore2-2.13.1}/README.md +0 -0
  14. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/__init__.py +0 -0
  15. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_api.py +0 -0
  16. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_async/__init__.py +0 -0
  17. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_async/connection_pool.py +0 -0
  18. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_async/http11.py +0 -0
  19. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_async/http2.py +0 -0
  20. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_async/interfaces.py +0 -0
  21. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_backends/__init__.py +0 -0
  22. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_backends/anyio.py +0 -0
  23. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_backends/auto.py +0 -0
  24. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_backends/base.py +0 -0
  25. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_backends/mock.py +0 -0
  26. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_backends/sync.py +0 -0
  27. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_backends/trio.py +0 -0
  28. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_exceptions.py +0 -0
  29. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_models.py +0 -0
  30. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_ssl.py +0 -0
  31. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_sync/__init__.py +0 -0
  32. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_sync/connection_pool.py +0 -0
  33. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_sync/http11.py +0 -0
  34. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_sync/http2.py +0 -0
  35. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_sync/interfaces.py +0 -0
  36. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_synchronization.py +0 -0
  37. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/_trace.py +0 -0
  38. {httpcore2-2.12.0 → httpcore2-2.13.1}/httpcore2/py.typed +0 -0
@@ -4,6 +4,27 @@ 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.13.1 (September 23rd, 2026)
8
+
9
+ ### Fixed
10
+
11
+ * Honor the `sni_hostname` extension for TLS inside HTTP proxy tunnels without applying it to the proxy's TLS connection.
12
+ ([#1223](https://github.com/pydantic/httpx2/pull/1223))
13
+ * Prefer HTTP/2 during TLS protocol negotiation when enabled, and stop advertising HTTP/1.1 when it is disabled.
14
+ ([#1155](https://github.com/pydantic/httpx2/pull/1155))
15
+
16
+ ## 2.13.0 (September 14th, 2026)
17
+
18
+ ### Changed
19
+
20
+ * Require Trio 0.34.0 or later for the `trio` extra.
21
+ ([#1179](https://github.com/pydantic/httpx2/pull/1179))
22
+
23
+ ### Fixed
24
+
25
+ * Avoid nested async generator finalization errors when streamed responses are abandoned early.
26
+ ([#1204](https://github.com/pydantic/httpx2/pull/1204))
27
+
7
28
  ## 2.12.0 (August 18th, 2026)
8
29
 
9
30
  No changes since `2.11.0`. Version bumped to stay in lockstep with `httpx2`.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: httpcore2
3
- Version: 2.12.0
3
+ Version: 2.13.1
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
@@ -36,7 +36,7 @@ Requires-Dist: h2<5,>=3; extra == 'http2'
36
36
  Provides-Extra: socks
37
37
  Requires-Dist: socksio==1.*; extra == 'socks'
38
38
  Provides-Extra: trio
39
- Requires-Dist: trio<1.0,>=0.33.0; extra == 'trio'
39
+ Requires-Dist: trio<1.0,>=0.34.0; extra == 'trio'
40
40
  Description-Content-Type: text/markdown
41
41
 
42
42
  # HTTPCore 2
@@ -152,6 +152,27 @@ 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.13.1 (September 23rd, 2026)
156
+
157
+ ### Fixed
158
+
159
+ * Honor the `sni_hostname` extension for TLS inside HTTP proxy tunnels without applying it to the proxy's TLS connection.
160
+ ([#1223](https://github.com/pydantic/httpx2/pull/1223))
161
+ * Prefer HTTP/2 during TLS protocol negotiation when enabled, and stop advertising HTTP/1.1 when it is disabled.
162
+ ([#1155](https://github.com/pydantic/httpx2/pull/1155))
163
+
164
+ ## 2.13.0 (September 14th, 2026)
165
+
166
+ ### Changed
167
+
168
+ * Require Trio 0.34.0 or later for the `trio` extra.
169
+ ([#1179](https://github.com/pydantic/httpx2/pull/1179))
170
+
171
+ ### Fixed
172
+
173
+ * Avoid nested async generator finalization errors when streamed responses are abandoned early.
174
+ ([#1204](https://github.com/pydantic/httpx2/pull/1204))
175
+
155
176
  ## 2.12.0 (August 18th, 2026)
156
177
 
157
178
  No changes since `2.11.0`. Version bumped to stay in lockstep with `httpx2`.
@@ -128,7 +128,7 @@ class AsyncHTTPConnection(AsyncConnectionInterface):
128
128
 
129
129
  if self._origin.scheme in (b"https", b"wss"):
130
130
  ssl_context = default_ssl_context() if self._ssl_context is None else self._ssl_context
131
- alpn_protocols = ["http/1.1", "h2"] if self._http2 else ["http/1.1"]
131
+ alpn_protocols = (["h2", "http/1.1"] if self._http1 else ["h2"]) if self._http2 else ["http/1.1"]
132
132
  ssl_context.set_alpn_protocols(alpn_protocols)
133
133
 
134
134
  kwargs = {
@@ -191,7 +191,7 @@ class AsyncForwardHTTPConnection(AsyncConnectionInterface):
191
191
  url=url,
192
192
  headers=headers,
193
193
  content=request.stream,
194
- extensions=request.extensions,
194
+ extensions={key: value for key, value in request.extensions.items() if key != "sni_hostname"},
195
195
  )
196
196
  return await self._connection.handle_async_request(proxy_request)
197
197
 
@@ -274,7 +274,7 @@ class AsyncTunnelHTTPConnection(AsyncConnectionInterface):
274
274
  method=b"CONNECT",
275
275
  url=connect_url,
276
276
  headers=connect_headers,
277
- extensions=request.extensions,
277
+ extensions={key: value for key, value in request.extensions.items() if key != "sni_hostname"},
278
278
  )
279
279
  connect_response = await self._connection.handle_async_request(connect_request)
280
280
 
@@ -289,12 +289,13 @@ class AsyncTunnelHTTPConnection(AsyncConnectionInterface):
289
289
 
290
290
  # Upgrade the stream to SSL
291
291
  ssl_context = default_ssl_context() if self._ssl_context is None else self._ssl_context
292
- alpn_protocols = ["http/1.1", "h2"] if self._http2 else ["http/1.1"]
292
+ alpn_protocols = (["h2", "http/1.1"] if self._http1 else ["h2"]) if self._http2 else ["http/1.1"]
293
293
  ssl_context.set_alpn_protocols(alpn_protocols)
294
294
 
295
+ server_hostname = request.extensions.get("sni_hostname") or self._remote_origin.host.decode("ascii")
295
296
  kwargs = {
296
297
  "ssl_context": ssl_context,
297
- "server_hostname": self._remote_origin.host.decode("ascii"),
298
+ "server_hostname": server_hostname,
298
299
  "timeout": timeout,
299
300
  }
300
301
  async with Trace("start_tls", logger, request, kwargs) as trace:
@@ -242,7 +242,9 @@ class AsyncSocks5Connection(AsyncConnectionInterface):
242
242
  # Upgrade the stream to SSL
243
243
  if self._remote_origin.scheme in (b"https", b"wss"):
244
244
  ssl_context = default_ssl_context() if self._ssl_context is None else self._ssl_context
245
- alpn_protocols = ["http/1.1", "h2"] if self._http2 else ["http/1.1"]
245
+ alpn_protocols = (
246
+ (["h2", "http/1.1"] if self._http1 else ["h2"]) if self._http2 else ["http/1.1"]
247
+ )
246
248
  ssl_context.set_alpn_protocols(alpn_protocols)
247
249
 
248
250
  kwargs = {
@@ -128,7 +128,7 @@ class HTTPConnection(ConnectionInterface):
128
128
 
129
129
  if self._origin.scheme in (b"https", b"wss"):
130
130
  ssl_context = default_ssl_context() if self._ssl_context is None else self._ssl_context
131
- alpn_protocols = ["http/1.1", "h2"] if self._http2 else ["http/1.1"]
131
+ alpn_protocols = (["h2", "http/1.1"] if self._http1 else ["h2"]) if self._http2 else ["http/1.1"]
132
132
  ssl_context.set_alpn_protocols(alpn_protocols)
133
133
 
134
134
  kwargs = {
@@ -191,7 +191,7 @@ class ForwardHTTPConnection(ConnectionInterface):
191
191
  url=url,
192
192
  headers=headers,
193
193
  content=request.stream,
194
- extensions=request.extensions,
194
+ extensions={key: value for key, value in request.extensions.items() if key != "sni_hostname"},
195
195
  )
196
196
  return self._connection.handle_request(proxy_request)
197
197
 
@@ -274,7 +274,7 @@ class TunnelHTTPConnection(ConnectionInterface):
274
274
  method=b"CONNECT",
275
275
  url=connect_url,
276
276
  headers=connect_headers,
277
- extensions=request.extensions,
277
+ extensions={key: value for key, value in request.extensions.items() if key != "sni_hostname"},
278
278
  )
279
279
  connect_response = self._connection.handle_request(connect_request)
280
280
 
@@ -289,12 +289,13 @@ class TunnelHTTPConnection(ConnectionInterface):
289
289
 
290
290
  # Upgrade the stream to SSL
291
291
  ssl_context = default_ssl_context() if self._ssl_context is None else self._ssl_context
292
- alpn_protocols = ["http/1.1", "h2"] if self._http2 else ["http/1.1"]
292
+ alpn_protocols = (["h2", "http/1.1"] if self._http1 else ["h2"]) if self._http2 else ["http/1.1"]
293
293
  ssl_context.set_alpn_protocols(alpn_protocols)
294
294
 
295
+ server_hostname = request.extensions.get("sni_hostname") or self._remote_origin.host.decode("ascii")
295
296
  kwargs = {
296
297
  "ssl_context": ssl_context,
297
- "server_hostname": self._remote_origin.host.decode("ascii"),
298
+ "server_hostname": server_hostname,
298
299
  "timeout": timeout,
299
300
  }
300
301
  with Trace("start_tls", logger, request, kwargs) as trace:
@@ -242,7 +242,9 @@ class Socks5Connection(ConnectionInterface):
242
242
  # Upgrade the stream to SSL
243
243
  if self._remote_origin.scheme in (b"https", b"wss"):
244
244
  ssl_context = default_ssl_context() if self._ssl_context is None else self._ssl_context
245
- alpn_protocols = ["http/1.1", "h2"] if self._http2 else ["http/1.1"]
245
+ alpn_protocols = (
246
+ (["h2", "http/1.1"] if self._http1 else ["h2"]) if self._http2 else ["http/1.1"]
247
+ )
246
248
  ssl_context.set_alpn_protocols(alpn_protocols)
247
249
 
248
250
  kwargs = {
@@ -5,15 +5,14 @@ import socket
5
5
  import sys
6
6
  import typing
7
7
  from collections.abc import (
8
- AsyncGenerator,
9
8
  AsyncIterable,
10
9
  AsyncIterator,
11
10
  Generator,
12
11
  Iterable,
13
12
  Iterator,
14
13
  )
15
- from contextlib import asynccontextmanager, contextmanager
16
- from inspect import isasyncgen
14
+ from contextlib import AbstractAsyncContextManager, aclosing, contextmanager, nullcontext
15
+ from types import AsyncGeneratorType
17
16
 
18
17
  T = typing.TypeVar("T")
19
18
 
@@ -48,18 +47,15 @@ def is_socket_readable(sock: socket.socket | None) -> bool:
48
47
  return bool(p.poll(0))
49
48
 
50
49
 
51
- @asynccontextmanager
52
- async def safe_async_iterate(
50
+ def safe_async_iterate(
53
51
  iterable_or_iterator: AsyncIterable[T] | AsyncIterator[T], /
54
- ) -> AsyncGenerator[AsyncIterator[T]]:
52
+ ) -> AbstractAsyncContextManager[AsyncIterator[T]]:
55
53
  iterator = (
56
54
  iterable_or_iterator if isinstance(iterable_or_iterator, AsyncIterator) else iterable_or_iterator.__aiter__()
57
55
  )
58
- try:
59
- yield iterator
60
- finally:
61
- if isasyncgen(iterator):
62
- await iterator.aclose()
56
+ if isinstance(iterator, AsyncGeneratorType):
57
+ return aclosing(iterator)
58
+ return nullcontext(iterator)
63
59
 
64
60
 
65
61
  @contextmanager
@@ -2,7 +2,7 @@
2
2
  requires = [
3
3
  "hatchling",
4
4
  "hatch-fancy-pypi-readme",
5
- "uv-dynamic-versioning>=0.14.0",
5
+ "uv-dynamic-versioning>=0.14.1",
6
6
  ]
7
7
  build-backend = "hatchling.build"
8
8
 
@@ -49,7 +49,7 @@ dependencies = ["truststore>=0.10", "h11>=0.16"]
49
49
  [project.optional-dependencies]
50
50
  http2 = ["h2>=3,<5"]
51
51
  socks = ["socksio==1.*"]
52
- trio = ["trio>=0.33.0,<1.0"]
52
+ trio = ["trio>=0.34.0,<1.0"]
53
53
  asyncio = ["anyio>=4.5.0,<5.0"]
54
54
 
55
55
  [project.urls]
File without changes
File without changes
File without changes
File without changes
File without changes