Skip to content

Commit 2f737ca

Browse files
committed
feat: add socket_options to Client and AsyncClient classes
1 parent 336204f commit 2f737ca

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

httpx/_client.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from ._models import Cookies, Headers, Request, Response
3030
from ._status_codes import codes
3131
from ._transports.base import AsyncBaseTransport, BaseTransport
32-
from ._transports.default import AsyncHTTPTransport, HTTPTransport
32+
from ._transports.default import SOCKET_OPTION, AsyncHTTPTransport, HTTPTransport
3333
from ._types import (
3434
AsyncByteStream,
3535
AuthTypes,
@@ -653,6 +653,7 @@ def __init__(
653653
timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
654654
follow_redirects: bool = False,
655655
limits: Limits = DEFAULT_LIMITS,
656+
socket_options: typing.Iterable[SOCKET_OPTION] | None = None,
656657
max_redirects: int = DEFAULT_MAX_REDIRECTS,
657658
event_hooks: None | (typing.Mapping[str, list[EventHook]]) = None,
658659
base_url: URL | str = "",
@@ -693,6 +694,7 @@ def __init__(
693694
http2=http2,
694695
limits=limits,
695696
transport=transport,
697+
socket_options=socket_options,
696698
)
697699
self._mounts: dict[URLPattern, BaseTransport | None] = {
698700
URLPattern(key): None
@@ -705,6 +707,7 @@ def __init__(
705707
http1=http1,
706708
http2=http2,
707709
limits=limits,
710+
socket_options=socket_options,
708711
)
709712
for key, proxy in proxy_map.items()
710713
}
@@ -723,6 +726,7 @@ def _init_transport(
723726
http1: bool = True,
724727
http2: bool = False,
725728
limits: Limits = DEFAULT_LIMITS,
729+
socket_options: typing.Iterable[SOCKET_OPTION] | None = None,
726730
transport: BaseTransport | None = None,
727731
) -> BaseTransport:
728732
if transport is not None:
@@ -735,6 +739,7 @@ def _init_transport(
735739
http1=http1,
736740
http2=http2,
737741
limits=limits,
742+
socket_options=socket_options,
738743
)
739744

740745
def _init_proxy_transport(
@@ -746,6 +751,7 @@ def _init_proxy_transport(
746751
http1: bool = True,
747752
http2: bool = False,
748753
limits: Limits = DEFAULT_LIMITS,
754+
socket_options: typing.Iterable[SOCKET_OPTION] | None = None,
749755
) -> BaseTransport:
750756
return HTTPTransport(
751757
verify=verify,
@@ -755,6 +761,7 @@ def _init_proxy_transport(
755761
http2=http2,
756762
limits=limits,
757763
proxy=proxy,
764+
socket_options=socket_options,
758765
)
759766

760767
def _transport_for_url(self, url: URL) -> BaseTransport:
@@ -1366,6 +1373,7 @@ def __init__(
13661373
timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
13671374
follow_redirects: bool = False,
13681375
limits: Limits = DEFAULT_LIMITS,
1376+
socket_options: typing.Iterable[SOCKET_OPTION] | None = None,
13691377
max_redirects: int = DEFAULT_MAX_REDIRECTS,
13701378
event_hooks: None | (typing.Mapping[str, list[EventHook]]) = None,
13711379
base_url: URL | str = "",
@@ -1407,6 +1415,7 @@ def __init__(
14071415
http2=http2,
14081416
limits=limits,
14091417
transport=transport,
1418+
socket_options=socket_options,
14101419
)
14111420

14121421
self._mounts: dict[URLPattern, AsyncBaseTransport | None] = {
@@ -1420,6 +1429,7 @@ def __init__(
14201429
http1=http1,
14211430
http2=http2,
14221431
limits=limits,
1432+
socket_options=socket_options,
14231433
)
14241434
for key, proxy in proxy_map.items()
14251435
}
@@ -1437,6 +1447,7 @@ def _init_transport(
14371447
http1: bool = True,
14381448
http2: bool = False,
14391449
limits: Limits = DEFAULT_LIMITS,
1450+
socket_options: typing.Iterable[SOCKET_OPTION] | None = None,
14401451
transport: AsyncBaseTransport | None = None,
14411452
) -> AsyncBaseTransport:
14421453
if transport is not None:
@@ -1449,6 +1460,7 @@ def _init_transport(
14491460
http1=http1,
14501461
http2=http2,
14511462
limits=limits,
1463+
socket_options=socket_options,
14521464
)
14531465

14541466
def _init_proxy_transport(
@@ -1460,6 +1472,7 @@ def _init_proxy_transport(
14601472
http1: bool = True,
14611473
http2: bool = False,
14621474
limits: Limits = DEFAULT_LIMITS,
1475+
socket_options: typing.Iterable[SOCKET_OPTION] | None = None,
14631476
) -> AsyncBaseTransport:
14641477
return AsyncHTTPTransport(
14651478
verify=verify,
@@ -1469,6 +1482,7 @@ def _init_proxy_transport(
14691482
http2=http2,
14701483
limits=limits,
14711484
proxy=proxy,
1485+
socket_options=socket_options,
14721486
)
14731487

14741488
def _transport_for_url(self, url: URL) -> AsyncBaseTransport:

0 commit comments

Comments
 (0)