Skip to content

Commit

Permalink
禁用http2
Browse files Browse the repository at this point in the history
  • Loading branch information
SMU-Rainflow committed Dec 27, 2024
1 parent c7c13f1 commit 6621809
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion httpx/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -672,7 +673,7 @@ def __init__(
trust_env=trust_env,
default_encoding=default_encoding,
)

if http2:
try:
import h2 # noqa
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -747,6 +750,7 @@ def _init_proxy_transport(
http2: bool = False,
limits: Limits = DEFAULT_LIMITS,
) -> BaseTransport:
http2=False
return HTTPTransport(
verify=verify,
cert=cert,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand All @@ -1461,6 +1467,7 @@ def _init_proxy_transport(
http2: bool = False,
limits: Limits = DEFAULT_LIMITS,
) -> AsyncBaseTransport:
http2 = False
return AsyncHTTPTransport(
verify=verify,
cert=cert,
Expand Down

0 comments on commit 6621809

Please sign in to comment.