]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Add documentation for socket_options network-options 3052/head
authorKar Petrosyan <92274156+karpetrosyan@users.noreply.github.com>
Thu, 13 Jun 2024 15:25:24 +0000 (19:25 +0400)
committerGitHub <noreply@github.com>
Thu, 13 Jun 2024 15:25:24 +0000 (19:25 +0400)
docs/advanced/network-options.md
httpx/_config.py

index 08329359d1c8bc7454b3676b5f84d154bc03476f..ea444d420642adf73ce5b6c25e6b32684b84d5cd 100644 (file)
@@ -26,7 +26,18 @@ Configure the local address that the socket should be bound too. The most common
 
 ### `socket_options`
 
-*TODO: Example*
+Configure the list of socket options to be applied to the underlying sockets used for network connections.
+For example, you can use it to explicitly specify which network interface should be used for the connection in this manner:
+
+```python
+import httpx
+
+socket_options = [(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, b"ETH999")]
+
+network_options = httpx.NetworkOptions(
+    socket_options=socket_options
+)
+```
 
 ### `uds`
 
index 736cfdf38d19ed76f03cc5e5957fde314d6a7fd6..168b4438fe94e26a2e2cc22eb8f1d1e708715a3d 100644 (file)
@@ -14,7 +14,7 @@ from ._types import CertTypes, HeaderTypes, TimeoutTypes, URLTypes, VerifyTypes
 from ._urls import URL
 from ._utils import get_ca_bundle_from_env
 
-__all__ = ["Limits", "Proxy", "Timeout", "create_ssl_context"]
+__all__ = ["Limits", "Proxy", "Timeout", "NetworkOptions", "create_ssl_context"]
 
 SOCKET_OPTION = typing.Union[
     typing.Tuple[int, int, int],