From: Florimond Manca Date: Mon, 17 Aug 2020 12:49:09 +0000 (+0200) Subject: Document Unix Domain Socket usage (#1186) X-Git-Tag: 0.14.2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34ba0e14b0d588860e408e6e21ec729af5667f7f;p=thirdparty%2Fhttpx.git Document Unix Domain Socket usage (#1186) --- diff --git a/docs/advanced.md b/docs/advanced.md index b5794474..7d16c941 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -827,6 +827,24 @@ low-level API. >>> client = httpx.Client(transport=transport) ``` +Similarly, `httpcore` provides a `uds` option for connecting via a Unix Domain Socket that is only available via this low-level API: + +```python +>>> import httpx, httpcore +>>> ssl_context = httpx.create_ssl_context() +>>> transport = httpcore.SyncConnectionPool( +... ssl_context=ssl_context, +... max_connections=100, +... max_keepalive_connections=20, +... keepalive_expiry=5.0, +... uds="/var/run/docker.sock", +... ) # Connect to the Docker API via a Unix Socket. +>>> client = httpx.Client(transport=transport) +>>> response = client.get("http://docker/info") +>>> response.json() +{"ID": "...", "Containers": 4, "Images": 74, ...} +``` + Unlike the `httpx.Client()`, the lower-level `httpcore` transport instances do not include any default values for configuring aspects such as the connection pooling details, so you'll need to provide more explicit