Refine docs phrasing on proxy routing (#1124)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Florimond Manca · committed by GitHub · parent 70cdd95 · Browse files · 1 file·+6 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+6 added−15 removed
- other:+6 added−15 removed
Provenance
- Commit
0fb28e8- Tree
e96c850- Author
Florimond Manca <florimond.manca@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
70cdd95
1 file changed+6 added−15 removed
modified:docs/advanced.md+6 added-15 removed
278 unmodified lines279 with httpx.Client(proxies="http://localhost:8030") as client:280 ...281 ```282 283-To route HTTP and HTTPS requests to 2 different proxies, respectively located at `http://localhost:8030`, and `http://localhost:8031`, pass a `dict` of proxy URLs:283+For more advanced use cases, pass a proxies `dict`. For example, to route HTTP and HTTPS requests to 2 different proxies, respectively located at `http://localhost:8030`, and `http://localhost:8031`, pass a `dict` of proxy URLs:284 285 ```python286 proxies = {287 "http": "http://localhost:8030",25 unmodified lines313 ```314 315 ### Routing316 317-HTTPX supports configuring which requests go through a given proxy and which don't based on the requested **scheme**, **domain**, **port**, or a combination of these.317+HTTPX provides fine-grained controls for deciding which requests should go through a proxy, and which shouldn't. This process is known as proxy routing.318 319+The `proxies` dictionary maps URL patterns ("proxy keys") to proxy URLs. HTTPX matches requested URLs against proxy keys to decide which proxy should be used, if any. Matching is done from most specific proxy keys (e.g. `https://<domain>:<port>`) to least specific ones (e.g. `https`).320+321+HTTPX supports routing proxies based on **scheme**, **domain**, **port**, or a combination of these.322+323 #### Wildcard routing324 325 Route everything through a proxy...326 2 unmodified lines329 "all": "http://localhost:8030",330 }331 ```332 329-(This is equivalent to `Client(..., proxies="http://localhost:8030")`.)330-333 #### Scheme routing334 335 Route HTTP requests through one proxy, and HTTPS requests through another...336 94 unmodified lines431 HTTP proxying can also be configured through environment variables, although with less fine-grained control.432 433 See documentation on [`HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`](/environment_variables/#http_proxy-https_proxy-all_proxy) for more information.434 433-#### Routing algorithm overview434-435-For reference, the proxy routing algorithm used by HTTPX is roughly as follows...436-437-1. Sort proxy keys in decreasing order of specificity. (For example, a proxy on `all://example.com` comes before a proxy on `all`.) _This is done on client instanciation._438-1. When making a request, go through sorted proxies, looking for a matching key...439- 1. If a key matches...440- 1. ...But the value is `None`, no proxy is used.441- 1. Otherwise, the associated proxy is used.442- 1. If no key matched, no proxy is used.443-435 ### Proxy mechanisms436 437 !!! note438 This section describes **advanced** proxy concepts and functionality.422 unmodified lines