From: Yeray Diaz Diaz Date: Wed, 13 May 2020 10:53:35 +0000 (+0100) Subject: Document pool_limits and SSL context on verify (#942) X-Git-Tag: 0.13.0~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=790a3ead5d5f493a09ff3990bdd50ba68ca4752c;p=thirdparty%2Fhttpx.git Document pool_limits and SSL context on verify (#942) Co-authored-by: Tom Christie --- diff --git a/docs/advanced.md b/docs/advanced.md index 8dd79390..5203258b 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -399,6 +399,22 @@ client = httpx.Client(timeout=timeout) response = client.get('http://example.com/') ``` +## Pool limit configuration + +You can control the connection pool size using the `pool_limits` keyword +argument on the client. It takes instances of `httpx.PoolLimits` which define: + +- `soft_limit`, number of allowable keep-alive connections, or `None` to always +allow. (Defaults 10) +- `hard_limit`, maximum number of allowable connections, or` None` for no limits. +(Default 100) + + +```python +limits = httpx.PoolLimits(soft_limit=5, hard_limit=10) +client = httpx.Client(pool_limits=limits) +``` + ## Multipart file encoding As mentioned in the [quickstart](/quickstart#sending-multipart-file-uploads) @@ -558,7 +574,18 @@ import httpx r = httpx.get("https://example.org", verify="path/to/client.pem") ``` -You can also disable the SSL verification... +Alternatively, you can pass a standard library `ssl.SSLContext`. + +```python +>>> import ssl +>>> import httpx +>>> context = ssl.create_default_context() +>>> context.load_verify_locations(cafile="/tmp/client.pem") +>>> httpx.get('https://example.org', verify=context) + +``` + +Or you can also disable the SSL verification entirely, which is _not_ recommended. ```python import httpx diff --git a/httpx/_config.py b/httpx/_config.py index 52255c26..12478821 100644 --- a/httpx/_config.py +++ b/httpx/_config.py @@ -290,7 +290,7 @@ class PoolLimits: * **soft_limit** - Allow the connection pool to maintain keep-alive connections below this point. - * **hard_limit** - The maximum number of concurrenct connections that may be + * **hard_limit** - The maximum number of concurrent connections that may be established. """