]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Document pool_limits and SSL context on verify (#942)
authorYeray Diaz Diaz <yeraydiazdiaz@gmail.com>
Wed, 13 May 2020 10:53:35 +0000 (11:53 +0100)
committerGitHub <noreply@github.com>
Wed, 13 May 2020 10:53:35 +0000 (11:53 +0100)
Co-authored-by: Tom Christie <tom@tomchristie.com>
docs/advanced.md
httpx/_config.py

index 8dd793906288cceac88ece5e2bec8f31ccfd299b..5203258bcafc0df16968b91150434a5c8462a076 100644 (file)
@@ -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)
+<Response [200 OK]>
+```
+
+Or you can also disable the SSL verification entirely, which is _not_ recommended.
 
 ```python
 import httpx
index 52255c26a6a34d72f9339b428dab4035ffb34e74..12478821a187d45cfb9bad86e6a7a00386c79245 100644 (file)
@@ -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.
     """