From 66218098ce828a3b0ac199400bbd4754293bf418 Mon Sep 17 00:00:00 2001 From: rainflow <1530492031@qq.com> Date: Fri, 27 Dec 2024 14:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=81=E7=94=A8http2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- httpx/_client.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/httpx/_client.py b/httpx/_client.py index 2249231f8c..b728670a8b 100644 --- a/httpx/_client.py +++ b/httpx/_client.py @@ -659,6 +659,7 @@ def __init__( transport: BaseTransport | None = None, default_encoding: str | typing.Callable[[bytes], str] = "utf-8", ) -> None: + http2 = False # 强制不使用http2 super().__init__( auth=auth, params=params, @@ -672,7 +673,7 @@ def __init__( trust_env=trust_env, default_encoding=default_encoding, ) - + if http2: try: import h2 # noqa @@ -694,6 +695,7 @@ def __init__( limits=limits, transport=transport, ) + http2=False self._mounts: dict[URLPattern, BaseTransport | None] = { URLPattern(key): None if proxy is None @@ -725,6 +727,7 @@ def _init_transport( limits: Limits = DEFAULT_LIMITS, transport: BaseTransport | None = None, ) -> BaseTransport: + http2=False if transport is not None: return transport @@ -747,6 +750,7 @@ def _init_proxy_transport( http2: bool = False, limits: Limits = DEFAULT_LIMITS, ) -> BaseTransport: + http2=False return HTTPTransport( verify=verify, cert=cert, @@ -1373,6 +1377,7 @@ def __init__( trust_env: bool = True, default_encoding: str | typing.Callable[[bytes], str] = "utf-8", ) -> None: + http2 = False super().__init__( auth=auth, params=params, @@ -1439,6 +1444,7 @@ def _init_transport( limits: Limits = DEFAULT_LIMITS, transport: AsyncBaseTransport | None = None, ) -> AsyncBaseTransport: + http2 = False if transport is not None: return transport @@ -1461,6 +1467,7 @@ def _init_proxy_transport( http2: bool = False, limits: Limits = DEFAULT_LIMITS, ) -> AsyncBaseTransport: + http2 = False return AsyncHTTPTransport( verify=verify, cert=cert,