As well as these optional installs:
-* `h2` - HTTP/2 support. *(Optional, with `httpx[http2]`)*
-* `socksio` - SOCKS proxy support. *(Optional, with `httpx[socks]`)*
-* `rich` - Rich terminal support. *(Optional, with `httpx[cli]`)*
-* `click` - Command line client support. *(Optional, with `httpx[cli]`)*
-* `brotli` or `brotlicffi` - Decoding for "brotli" compressed responses. *(Optional, with `httpx[brotli]`)*
+* `anyio` - Async support for `asyncio`. *(Optional, with `httpx['asyncio']`)*
+* `trio` - Async support for `trio`. *(Optional, with `httpx['trio']`)*
+* `h2` - HTTP/2 support. *(Optional, with `httpx['http2']`)*
+* `socksio` - SOCKS proxy support. *(Optional, with `httpx['socks']`)*
+* `rich` - Rich terminal support. *(Optional, with `httpx['cli']`)*
+* `click` - Command line client support. *(Optional, with `httpx['cli']`)*
+* `brotli` or `brotlicffi` - Decoding for "brotli" compressed responses. *(Optional, with `httpx['brotli']`)*
+ * `zstandard` - Decoding for "zstd" compressed responses. *(Optional, with `httpx[zstd]`)*
A huge amount of credit is due to `requests` for the API layout that
much of this work follows, as well as to `urllib3` for plenty of design
+ from __future__ import annotations
+
import typing
-import sniffio
-
from .._models import Request, Response
from .._types import AsyncByteStream
from .base import AsyncBaseTransport
Event = typing.Union[asyncio.Event, trio.Event]
- _Message = typing.Dict[str, typing.Any]
+ _Message = typing.MutableMapping[str, typing.Any]
_Receive = typing.Callable[[], typing.Awaitable[_Message]]
_Send = typing.Callable[
- [typing.Dict[str, typing.Any]], typing.Coroutine[None, None, None]
+ [typing.MutableMapping[str, typing.Any]], typing.Awaitable[None]
]
_ASGIApp = typing.Callable[
- [typing.Dict[str, typing.Any], _Receive, _Send], typing.Coroutine[None, None, None]
+ [typing.MutableMapping[str, typing.Any], _Receive, _Send], typing.Awaitable[None]
]
+ __all__ = ["ASGITransport"]
+
-def create_event() -> Event:
+def create_event() -> "Event":
+ import sniffio
+
if sniffio.current_async_library() == "trio":
import trio
http2: bool = False,
limits: Limits = DEFAULT_LIMITS,
trust_env: bool = True,
- proxy: typing.Optional[ProxyTypes] = None,
- uds: typing.Optional[str] = None,
- local_address: typing.Optional[str] = None,
+ proxy: ProxyTypes | None = None,
+ uds: str | None = None,
+ local_address: str | None = None,
retries: int = 0,
- socket_options: typing.Optional[typing.Iterable[SOCKET_OPTION]] = None,
+ socket_options: typing.Iterable[SOCKET_OPTION] | None = None,
) -> None:
+ try:
+ import sniffio # noqa: F401
+ except ImportError: # pragma: nocover
+ raise RuntimeError(
+ "Using httpx in async mode, but neither "
+ "httpx['asyncio'] or asyncio['trio'] is installed."
+ )
+
ssl_context = create_ssl_context(verify=verify, cert=cert, trust_env=trust_env)
proxy = Proxy(url=proxy) if isinstance(proxy, (str, URL)) else proxy
"rich>=10,<14",
]
http2 = [
- "h2>=3,<5",
+ "httpcore[http2]",
]
socks = [
- "socksio==1.*",
+ "httpcore[socks]",
+]
+asyncio = [
+ "httpcore[asyncio]"
+]
+trio = [
+ "httpcore[trio]"
]
+ zstd = [
+ "zstandard>=0.18.0",
+ ]
[project.scripts]
httpx = "httpx:main"
# On the other hand, we're not pinning package dependencies, because our tests
# needs to pass with the latest version of the packages.
# Reference: https://github.com/encode/httpx/pull/1721#discussion_r661241588
- -e .[asyncio,trio,brotli,cli,http2,socks]
--e .[brotli,cli,http2,socks,zstd]
++-e .[asyncio,trio,brotli,cli,http2,socks,zstd]
# Optional charset auto-detection
# Used in our test cases
chardet==5.2.0
# Documentation
- mkdocs==1.5.3
+ mkdocs==1.6.1
mkautodoc==0.2.0
- mkdocs-material==9.5.3
+ mkdocs-material==9.5.34
# Packaging
- build==1.0.3
- twine==4.0.2
+ build==1.2.1
+ twine==5.1.1
# Tests & Linting
- coverage[toml]==7.4.0
- cryptography==41.0.7
- mypy==1.8.0
- pytest==7.4.4
- ruff==0.1.9
- trio==0.22.2
+ coverage[toml]==7.6.1
+ cryptography==43.0.1
+ mypy==1.11.2
+ pytest==8.3.2
+ ruff==0.6.3
+ trio==0.26.2
-trio-typing==0.10.0
trustme==1.1.0
- uvicorn==0.24.0.post1
+ uvicorn==0.30.6