Add documentation for socket_options

This commit is contained in:
Kar Petrosyan 2024-06-13 19:25:24 +04:00 committed by GitHub
parent b9d9045a8b
commit acd83dac70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View 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`

View 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],