Skip to content
Myr

advanced.md

This file

Path

docs/advanced.md

980 lines · 33.6 KiB · Markdown

Last changed by

Add progress to streaming download (#1268)cdelerbefore adoptioned16eb3

History of this file

Take it

The walk stopped after 200 commits: lines older than 5cf1acc point at it.

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 1–58why, one step back
1# Advanced Usage
23## Client Instances45!!! hint6 If you are coming from Requests, `httpx.Client()` is what you can use instead of `requests.Session()`.78### Why use a Client?910!!! note "TL;DR"11 If you do anything more than experimentation, one-off scripts, or prototypes, then you should use a `Client` instance.1213#### More efficient usage of network resources1415When you make requests using the top-level API as documented in the [Quickstart](/quickstart) guide, HTTPX has to establish a new connection _for every single request_ (connections are not reused). As the number of requests to a host increases, this quickly becomes inefficient.1617On the other hand, a `Client` instance uses [HTTP connection pooling](https://en.wikipedia.org/wiki/HTTP_persistent_connection). This means that when you make several requests to the same host, the `Client` will reuse the underlying TCP connection, instead of recreating one for every single request.1819This can bring **significant performance improvements** compared to using the top-level API, including:2021- Reduced latency across requests (no handshaking).22- Reduced CPU usage and round-trips.23- Reduced network congestion.2425#### Extra features2627`Client` instances also support features that aren't available at the top-level API, such as:2829- Cookie persistance across requests.30- Applying configuration across all outgoing requests.31- Sending requests through HTTP proxies.32- Using [HTTP/2](/http2).3334The other sections on this page go into further detail about what you can do with a `Client` instance.3536### Usage3738The recommended way to use a `Client` is as a context manager. This will ensure that connections are properly cleaned up when leaving the `with` block:3940```python41with httpx.Client() as client:42 ...43```4445Alternatively, you can explicitly close the connection pool without block-usage using `.close()`:4647```python48client = httpx.Client()49try:50 ...51finally:52 client.close()53```5455### Making requests5657Once you have a `Client`, you can send requests using `.get()`, `.post()`, etc. For example:58

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 59why, one step back
59```pycon

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 60–70why, one step back
60>>> with httpx.Client() as client:
61... r = client.get('https://example.com')62...63>>> r64<Response [200 OK]>65```6667These methods accept the same arguments as `httpx.get()`, `httpx.post()`, etc. This means that all features documented in the [Quickstart](/quickstart) guide are also available at the client level.6869For example, to send a request with custom headers:70

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 71why, one step back
71```pycon

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 72–85why, one step back
72>>> with httpx.Client() as client:
73... headers = {'X-Custom': 'value'}74... r = client.get('https://example.com', headers=headers)75...76>>> r.request.headers['X-Custom']77'value'78```7980### Sharing configuration across requests8182Clients allow you to apply configuration to all outgoing requests by passing parameters to the `Client` constructor.8384For example, to apply a set of custom headers _on every request_:85

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 86why, one step back
86```pycon

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 87–101why, one step back
87>>> url = 'http://httpbin.org/headers'
88>>> headers = {'user-agent': 'my-app/0.0.1'}89>>> with httpx.Client(headers=headers) as client:90... r = client.get(url)91...92>>> r.json()['headers']['User-Agent']93'my-app/0.0.1'94```9596### Merging of configuration9798When a configuration option is provided at both the client-level and request-level, one of two things can happen:99100- For headers, query parameters and cookies, the values are combined together. For example:101

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 102why, one step back
102```pycon

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 103–119why, one step back
103>>> headers = {'X-Auth': 'from-client'}
104>>> params = {'client_id': 'client1'}105>>> with httpx.Client(headers=headers, params=params) as client:106... headers = {'X-Custom': 'from-request'}107... params = {'request_id': 'request1'}108... r = client.get('https://example.com', headers=headers, params=params)109...110>>> r.request.url111URL('https://example.com?client_id=client1&request_id=request1')112>>> r.request.headers['X-Auth']113'from-client'114>>> r.request.headers['X-Custom']115'from-request'116```117118- For all other parameters, the request-level value takes priority. For example:119

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 120why, one step back
120```pycon

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 121–137why, one step back
121>>> with httpx.Client(auth=('tom', 'mot123')) as client:
122... r = client.get('https://example.com', auth=('alice', 'ecila123'))123...124>>> _, _, auth = r.request.headers['Authorization'].partition(' ')125>>> import base64126>>> base64.b64decode(auth)127b'alice:ecila123'128```129130If you need finer-grained control on the merging of client-level and request-level parameters, see [Request instances](#request-instances).131132### Other Client-only configuration options133134Additionally, `Client` accepts some configuration options that aren't available at the request level.135136For example, `base_url` allows you to prepend an URL to all outgoing requests:137

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 138why, one step back
138```pycon

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 139–175why, one step back
139>>> with httpx.Client(base_url='http://httpbin.org') as client:
140... r = client.get('/headers')141...142>>> r.request.url143URL('http://httpbin.org/headers')144```145146For a list of all available client parameters, see the [`Client`](/api/#client) API reference.147148## Calling into Python Web Apps149150You can configure an `httpx` client to call directly into a Python web application using the WSGI protocol.151152This is particularly useful for two main use-cases:153154* Using `httpx` as a client inside test cases.155* Mocking out external services during tests or in dev/staging environments.156157Here's an example of integrating against a Flask application:158159```python160from flask import Flask161import httpx162163164app = Flask(__name__)165166@app.route("/")167def hello():168 return "Hello World!"169170with httpx.Client(app=app, base_url="http://testserver") as client:171 r = client.get("/")172 assert r.status_code == 200173 assert r.text == "Hello World!"174```175

Transport API (#963)Yeray Diaz Diazbefore adoptiond2816c9

line 176why, one step back
176For some more complex cases you might need to customize the WSGI transport. This allows you to:

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 177–185why, one step back
177
178* Inspect 500 error responses rather than raise exceptions by setting `raise_app_exceptions=False`.179* Mount the WSGI application at a subpath by setting `script_name` (WSGI).180* Use a given client address for requests by setting `remote_addr` (WSGI).181182For example:183184```python185# Instantiate a client that makes WSGI requests with a client IP of "1.2.3.4".

Transport API (#963)Yeray Diaz Diazbefore adoptiond2816c9

lines 186–187why, one step back
186transport = httpx.WSGITransport(app=app, remote_addr="1.2.3.4")
187with httpx.Client(transport=transport, base_url="http://testserver") as client:

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 188–223why, one step back
188 ...
189```190191## Request instances192193For maximum control on what gets sent over the wire, HTTPX supports building explicit [`Request`](/api#request) instances:194195```python196request = httpx.Request("GET", "https://example.com")197```198199To dispatch a `Request` instance across to the network, create a [`Client` instance](#client-instances) and use `.send()`:200201```python202with httpx.Client() as client:203 response = client.send(request)204 ...205```206207If you need to mix client-level and request-level options in a way that is not supported by the default [Merging of parameters](#merging-of-parameters), you can use `.build_request()` and then make arbitrary modifications to the `Request` instance. For example:208209```python210headers = {"X-Api-Key": "...", "X-Client-ID": "ABC123"}211212with httpx.Client(headers=headers) as client:213 request = client.build_request("GET", "https://api.example.com")214215 print(request.headers["X-Client-ID"]) # "ABC123"216217 # Don't send the API key for this particular request.218 del request.headers["X-Api-Key"]219220 response = client.send(request)221 ...222```223

Add progress to streaming download (#1268)cdelerbefore adoptioned16eb3

lines 224–251why, one step back
224## Monitoring download progress
225226If you need to monitor download progress of large responses, you can use response streaming and inspect the `response.num_bytes_downloaded` property.227228This interface is required for properly determining download progress, because the total number of bytes returned by `response.content` or `response.iter_content()` will not always correspond with the raw content length of the response if HTTP response compression is being used.229230For example, showing a progress bar using the [`tqdm`](https://github.com/tqdm/tqdm) library while a response is being downloaded could be done like this…231232```python233import tempfile234235import httpx236from tqdm import tqdm237238with tempfile.NamedTemporaryFile() as download_file:239 url = "https://speed.hetzner.de/100MB.bin"240 with httpx.stream("GET", url) as response:241 total = int(response.headers["Content-Length"])242243 with tqdm(total=total, unit_scale=True, unit_divisor=1024, unit="B") as progress:244 num_bytes_downloaded = response.num_bytes_downloaded245 for chunk in response.iter_bytes():246 download_file.write(chunk)247 progress.update(response.num_bytes_downloaded - num_bytes_downloaded)248 num_bytes_downloaded = response.num_bytes_downloaded249 print(f"The total download size is {response.num_bytes_downloaded} bytes")250```251

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 252–262why, one step back
252## .netrc Support
253254HTTPX supports .netrc file. In `trust_env=True` cases, if auth parameter is255not defined, HTTPX tries to add auth into request's header from .netrc file.256257!!! note258 The NETRC file is cached across requests made by a client.259 If you need to refresh the cache (e.g. because the NETRC file has changed),260 you should create a new client or restart the interpreter.261262As default `trust_env` is true. To set false:

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 263why, one step back
263```pycon

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 264–270why, one step back
264>>> httpx.get('https://example.org/', trust_env=False)
265```266267If `NETRC` environment is empty, HTTPX tries to use default files.268(`~/.netrc`, `~/_netrc`)269270To change `NETRC` environment:

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 271why, one step back
271```pycon

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 272–292why, one step back
272>>> import os
273>>> os.environ["NETRC"] = "my_default_folder/.my_netrc"274```275276.netrc file content example:277```278machine netrcexample.org279login example-username280password example-password281282...283```284285When using `Client` instances, `trust_env` should be set on the client itself, rather that on the request methods:286287```python288client = httpx.Client(trust_env=False)289```290291## HTTP Proxying292

Add `proxies` parameter to top-level API functions (#1198)Joebefore adoption84ca201

line 293why, one step back
293HTTPX supports setting up [HTTP proxies](https://en.wikipedia.org/wiki/Proxy_server#Web_proxy_servers) via the `proxies` parameter to be passed on client initialization or top-level API functions like `httpx.get(..., proxies=...)`.

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

line 294why, one step back
294

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 295–305why, one step back
295_Note: SOCKS proxies are not supported yet._
296297<div align="center">298 <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Open_proxy_h2g2bob.svg/480px-Open_proxy_h2g2bob.svg.png"/>299 <figcaption><em>Diagram of how a proxy works (source: Wikipedia). The left hand side "Internet" blob may be your HTTPX client requesting <code>example.com</code> through a proxy.</em></figcaption>300</div>301302### Example303304To route all traffic (HTTP and HTTPS) to a proxy located at `http://localhost:8030`, pass the proxy URL to the client...305

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

line 306why, one step back
306```python

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 307–308why, one step back
307with httpx.Client(proxies="http://localhost:8030") as client:
308 ...

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 309–310why, one step back
309```
310

Refine docs phrasing on proxy routing (#1124)Florimond Mancabefore adoption0fb28e8

line 311why, one step back
311For 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:

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

line 312why, one step back
312

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 313–314why, one step back
313```python
314proxies = {

Raise warning if proxy key is eg. "all" instead of "all://". (#1127)cdelerbefore adoption7279ed4

lines 315–316why, one step back
315 "http://": "http://localhost:8030",
316 "https://": "http://localhost:8031",

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

line 317why, one step back
317}

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

line 318why, one step back
318

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 319–325why, one step back
319with httpx.Client(proxies=proxies) as client:
320 ...321```322323For detailed information about proxy routing, see the [Routing](#routing) section.324325!!! tip "Gotcha"

Raise warning if proxy key is eg. "all" instead of "all://". (#1127)cdelerbefore adoption7279ed4

line 326why, one step back
326 In most cases, the proxy URL for the `https://` key _should_ use the `http://` scheme (that's not a typo!).

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 327–335why, one step back
327
328 This is because HTTP proxying requires initiating a connection with the proxy server. While it's possible that your proxy supports doing it via HTTPS, most proxies only support doing it via HTTP.329330 For more information, see [FORWARD vs TUNNEL](#forward-vs-tunnel).331332### Authentication333334Proxy credentials can be passed as the `userinfo` section of the proxy URL. For example:335

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

line 336why, one step back
336```python

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

line 337why, one step back
337proxies = {

Raise warning if proxy key is eg. "all" instead of "all://". (#1127)cdelerbefore adoption7279ed4

line 338why, one step back
338 "http://": "http://username:password@localhost:8030",

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 339–340why, one step back
339 # ...
340}

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 341–342why, one step back
341```
342

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

line 343why, one step back
343### Routing

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

line 344why, one step back
344

Refine docs phrasing on proxy routing (#1124)Florimond Mancabefore adoption0fb28e8

line 345why, one step back
345HTTPX provides fine-grained controls for deciding which requests should go through a proxy, and which shouldn't. This process is known as proxy routing.

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

line 346why, one step back
346

Raise warning if proxy key is eg. "all" instead of "all://". (#1127)cdelerbefore adoption7279ed4

line 347why, one step back
347The `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://`).

Refine docs phrasing on proxy routing (#1124)Florimond Mancabefore adoption0fb28e8

lines 348–350why, one step back
348
349HTTPX supports routing proxies based on **scheme**, **domain**, **port**, or a combination of these.350

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

line 351why, one step back
351#### Wildcard routing

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

line 352why, one step back
352

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 353–354why, one step back
353Route everything through a proxy...
354

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

line 355why, one step back
355```python

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

line 356why, one step back
356proxies = {

Raise warning if proxy key is eg. "all" instead of "all://". (#1127)cdelerbefore adoption7279ed4

line 357why, one step back
357 "all://": "http://localhost:8030",

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

line 358why, one step back
358}

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 359–360why, one step back
359```
360

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 361–366why, one step back
361#### Scheme routing
362363Route HTTP requests through one proxy, and HTTPS requests through another...364365```python366proxies = {

Raise warning if proxy key is eg. "all" instead of "all://". (#1127)cdelerbefore adoption7279ed4

lines 367–368why, one step back
367 "http://": "http://localhost:8030",
368 "https://": "http://localhost:8031",

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 369–432why, one step back
369}
370```371372#### Domain routing373374Proxy all requests on domain "example.com", let other requests pass through...375376```python377proxies = {378 "all://example.com": "http://localhost:8030",379}380```381382Proxy HTTP requests on domain "example.com", let HTTPS and other requests pass through...383384```python385proxies = {386 "http://example.com": "http://localhost:8030",387}388```389390Proxy all requests to "example.com" and its subdomains, let other requests pass through...391392```python393proxies = {394 "all://*example.com": "http://localhost:8030",395}396```397398Proxy all requests to strict subdomains of "example.com", let "example.com" and other requests pass through...399400```python401proxies = {402 "all://*.example.com": "http://localhost:8030",403}404```405406#### Port routing407408Proxy HTTPS requests on port 1234 to "example.com"...409410```python411proxies = {412 "https://example.com:1234": "http://localhost:8030",413}414```415416Proxy all requests on port 1234...417418```python419proxies = {420 "all://*:1234": "http://localhost:8030",421}422```423424#### No-proxy support425426It is also possible to define requests that _shouldn't_ be routed through proxies.427428To do so, pass `None` as the proxy URL. For example...429430```python431proxies = {432 # Route requests through a proxy by default...

Raise warning if proxy key is eg. "all" instead of "all://". (#1127)cdelerbefore adoption7279ed4

line 433why, one step back
433 "all://": "http://localhost:8031",

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 434–445why, one step back
434 # Except those for "example.com".
435 "all://example.com": None,436}437```438439#### Complex configuration example440441You can combine the routing features outlined above to build complex proxy routing configurations. For example...442443```python444proxies = {445 # Route all traffic through a proxy by default...

Raise warning if proxy key is eg. "all" instead of "all://". (#1127)cdelerbefore adoption7279ed4

line 446why, one step back
446 "all://": "http://localhost:8030",

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 447–464why, one step back
447 # But don't use proxies for HTTPS requests to "domain.io"...
448 "https://domain.io": None,449 # And use another proxy for requests to "example.com" and its subdomains...450 "all://*example.com": "http://localhost:8031",451 # And yet another proxy if HTTP is used,452 # and the "internal" subdomain on port 5550 is requested...453 "http://internal.example.com:5550": "http://localhost:8032",454}455```456457#### Environment variables458459HTTP proxying can also be configured through environment variables, although with less fine-grained control.460461See documentation on [`HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`](/environment_variables/#http_proxy-https_proxy-all_proxy) for more information.462463### Proxy mechanisms464

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

line 465why, one step back
465!!! note

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

line 466why, one step back
466 This section describes **advanced** proxy concepts and functionality.

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

line 467why, one step back
467

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

line 468why, one step back
468#### FORWARD vs TUNNEL

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

line 469why, one step back
469

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 470–505why, one step back
470In general, the flow for making an HTTP request through a proxy is as follows:
4714721. The client connects to the proxy (initial connection request).4731. The proxy somehow transfers data to the server on your behalf.474475How exactly step 2/ is performed depends on which of two proxying mechanisms is used:476477* **Forwarding**: the proxy makes the request for you, and sends back the response it obtained from the server.478* **Tunneling**: the proxy establishes a TCP connection to the server on your behalf, and the client reuses this connection to send the request and receive the response. This is known as an [HTTP Tunnel](https://en.wikipedia.org/wiki/HTTP_tunnel). This mechanism is how you can access websites that use HTTPS from an HTTP proxy (the client "upgrades" the connection to HTTPS by performing the TLS handshake with the server over the TCP connection provided by the proxy).479480#### Default behavior481482Given the technical definitions above, by default (and regardless of whether you're using an HTTP or HTTPS proxy), HTTPX will:483484* Use forwarding for HTTP requests.485* Use tunneling for HTTPS requests.486487This ensures that you can make HTTP and HTTPS requests in all cases (i.e. regardless of which type of proxy you're using).488489#### Forcing the proxy mechanism490491In most cases, the default behavior should work just fine as well as provide enough security.492493But if you know what you're doing and you want to force which mechanism to use, you can do so by passing an `httpx.Proxy()` instance, setting the `mode` to either `FORWARD_ONLY` or `TUNNEL_ONLY`. For example...494495```python496# Route all requests through an HTTPS proxy, using tunneling only.497proxies = httpx.Proxy(498 url="https://localhost:8030",499 mode="TUNNEL_ONLY",500)501502with httpx.Client(proxies=proxies) as client:503 # This HTTP request will be tunneled instead of forwarded.504 r = client.get("http://example.com")505```

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 506–555why, one step back
506
507## Timeout Configuration508509HTTPX is careful to enforce timeouts everywhere by default.510511The default behavior is to raise a `TimeoutException` after 5 seconds of512network inactivity.513514### Setting and disabling timeouts515516You can set timeouts for an individual request:517518```python519# Using the top-level API:520httpx.get('http://example.com/api/v1/example', timeout=10.0)521522# Using a client instance:523with httpx.Client() as client:524 client.get("http://example.com/api/v1/example", timeout=10.0)525```526527Or disable timeouts for an individual request:528529```python530# Using the top-level API:531httpx.get('http://example.com/api/v1/example', timeout=None)532533# Using a client instance:534with httpx.Client() as client:535 client.get("http://example.com/api/v1/example", timeout=None)536```537538### Setting a default timeout on a client539540You can set a timeout on a client instance, which results in the given541`timeout` being used as the default for requests made with this client:542543```python544client = httpx.Client() # Use a default 5s timeout everywhere.545client = httpx.Client(timeout=10.0) # Use a default 10s timeout everywhere.546client = httpx.Client(timeout=None) # Disable all timeouts by default.547```548549### Fine tuning the configuration550551HTTPX also allows you to specify the timeout behavior in more fine grained detail.552553There are four different types of timeouts that may occur. These are **connect**,554**read**, **write**, and **pool** timeouts.555

Switch to more concise Timeout parameters (#1111)Florimond Mancabefore adoption26cd4f5

line 556why, one step back
556* The **connect** timeout specifies the maximum amount of time to wait until

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 557–558why, one step back
557a connection to the requested host is established. If HTTPX is unable to connect
558within this time frame, a `ConnectTimeout` exception is raised.

Switch to more concise Timeout parameters (#1111)Florimond Mancabefore adoption26cd4f5

line 559why, one step back
559* The **read** timeout specifies the maximum duration to wait for a chunk of

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 560–561why, one step back
560data to be received (for example, a chunk of the response body). If HTTPX is
561unable to receive data within this time frame, a `ReadTimeout` exception is raised.

Switch to more concise Timeout parameters (#1111)Florimond Mancabefore adoption26cd4f5

line 562why, one step back
562* The **write** timeout specifies the maximum duration to wait for a chunk of

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 563–564why, one step back
563data to be sent (for example, a chunk of the request body). If HTTPX is unable
564to send data within this time frame, a `WriteTimeout` exception is raised.

Switch to more concise Timeout parameters (#1111)Florimond Mancabefore adoption26cd4f5

line 565why, one step back
565* The **pool** timeout specifies the maximum duration to wait for acquiring

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 566–574why, one step back
566a connection from the connection pool. If HTTPX is unable to acquire a connection
567within this time frame, a `PoolTimeout` exception is raised. A related568configuration here is the maximum number of allowable connections in the569connection pool, which is configured by the `pool_limits`.570571You can configure the timeout behavior for any of these values...572573```python574# A client with a 60s timeout for connecting, and a 10s timeout elsewhere.

Switch to more concise Timeout parameters (#1111)Florimond Mancabefore adoption26cd4f5

line 575why, one step back
575timeout = httpx.Timeout(10.0, connect=60.0)

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 576–580why, one step back
576client = httpx.Client(timeout=timeout)
577578response = client.get('http://example.com/')579```580

Document pool_limits and SSL context on verify (#942)Yeray Diaz Diazbefore adoption790a3ea

lines 581–582why, one step back
581## Pool limit configuration
582

Rename PoolLimits to Limits (#1113)Florimond Mancabefore adoptionf67e925

lines 583–584why, one step back
583You can control the connection pool size using the `limits` keyword
584argument on the client. It takes instances of `httpx.Limits` which define:

Document pool_limits and SSL context on verify (#942)Yeray Diaz Diazbefore adoption790a3ea

line 585why, one step back
585

Rename pool limit options (#968)Tom Christiebefore adoption991915a

line 586why, one step back
586- `max_keepalive`, number of allowable keep-alive connections, or `None` to always

Document pool_limits and SSL context on verify (#942)Yeray Diaz Diazbefore adoption790a3ea

line 587why, one step back
587allow. (Defaults 10)

Rename pool limit options (#968)Tom Christiebefore adoption991915a

line 588why, one step back
588- `max_connections`, maximum number of allowable connections, or` None` for no limits.

Document pool_limits and SSL context on verify (#942)Yeray Diaz Diazbefore adoption790a3ea

lines 589–592why, one step back
589(Default 100)
590591592```python

Rename PoolLimits to Limits (#1113)Florimond Mancabefore adoptionf67e925

lines 593–594why, one step back
593limits = httpx.Limits(max_keepalive=5, max_connections=10)
594client = httpx.Client(limits=limits)

Document pool_limits and SSL context on verify (#942)Yeray Diaz Diazbefore adoption790a3ea

lines 595–596why, one step back
595```
596

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 597–602why, one step back
597## Multipart file encoding
598599As mentioned in the [quickstart](/quickstart#sending-multipart-file-uploads)600multipart file encoding is available by passing a dictionary with the601name of the payloads as keys and either tuple of elements or a file-like object or a string as values.602

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 603why, one step back
603```pycon

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 604–627why, one step back
604>>> files = {'upload-file': ('report.xls', open('report.xls', 'rb'), 'application/vnd.ms-excel')}
605>>> r = httpx.post("https://httpbin.org/post", files=files)606>>> print(r.text)607{608 ...609 "files": {610 "upload-file": "<... binary content ...>"611 },612 ...613}614```615616More specifically, if a tuple is used as a value, it must have between 2 and 3 elements:617618- The first element is an optional file name which can be set to `None`.619- The second element may be a file-like object or a string which will be automatically620encoded in UTF-8.621- An optional third element can be used to specify the622[MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_Types)623of the file being uploaded. If not specified HTTPX will attempt to guess the MIME type based624on the file name, with unknown file extensions defaulting to "application/octet-stream".625If the file name is explicitly set to `None` then HTTPX will not include a content-type626MIME header field.627

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 628why, one step back
628```pycon

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 629–641why, one step back
629>>> files = {'upload-file': (None, 'text content', 'text/plain')}
630>>> r = httpx.post("https://httpbin.org/post", files=files)631>>> print(r.text)632{633 ...634 "files": {},635 "form": {636 "upload-file": "text-content"637 },638 ...639}640```641

Add note on streaming uploads (#973)Florimond Mancabefore adoptiona58be59

lines 642–643why, one step back
642!!! tip
643 It is safe to upload large files this way. File uploads are streaming by default, meaning that only one chunk will be loaded into memory at a time.

Advanced transport docs (#1165)Tom Christiebefore adoption477824a

line 644why, one step back
644

Add note on data fields in multipart form encoding (#1022)Florimond Mancabefore adoption0f7d644

line 645why, one step back
645 Non-file data fields can be included in the multipart form using by passing them to `data=...`.

Advanced transport docs (#1165)Tom Christiebefore adoption477824a

line 646why, one step back
646

Add support for multiple files per POST field (#1032)euri10before adoption4d28795

lines 647–648why, one step back
647You can also send multiple files in one go with a multiple file field form.
648To do that, pass a list of `(field, <file>)` items instead of a dictionary, allowing you to pass multiple items with the same `field`.

Advanced transport docs (#1165)Tom Christiebefore adoption477824a

line 649why, one step back
649For instance this request sends 2 files, `foo.png` and `bar.png` in one request on the `images` form field:

Add support for multiple files per POST field (#1032)euri10before adoption4d28795

line 650why, one step back
650

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 651why, one step back
651```pycon

Add support for multiple files per POST field (#1032)euri10before adoption4d28795

lines 652–655why, one step back
652>>> files = [('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),
653 ('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]654>>> r = httpx.post("https://httpbin.org/post", files=files)655```

Add note on data fields in multipart form encoding (#1022)Florimond Mancabefore adoption0f7d644

line 656why, one step back
656

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 657–754why, one step back
657## Customizing authentication
658659When issuing requests or instantiating a client, the `auth` argument can be used to pass an authentication scheme to use. The `auth` argument may be one of the following...660661* A two-tuple of `username`/`password`, to be used with basic authentication.662* An instance of `httpx.BasicAuth()` or `httpx.DigestAuth()`.663* A callable, accepting a request and returning an authenticated request instance.664* A subclass of `httpx.Auth`.665666The most involved of these is the last, which allows you to create authentication flows involving one or more requests. A subclass of `httpx.Auth` should implement `def auth_flow(request)`, and yield any requests that need to be made...667668```python669class MyCustomAuth(httpx.Auth):670 def __init__(self, token):671 self.token = token672673 def auth_flow(self, request):674 # Send the request, with a custom `X-Authentication` header.675 request.headers['X-Authentication'] = self.token676 yield request677```678679If the auth flow requires more that one request, you can issue multiple yields, and obtain the response in each case...680681```python682class MyCustomAuth(httpx.Auth):683 def __init__(self, token):684 self.token = token685686 def auth_flow(self, request):687 response = yield request688 if response.status_code == 401:689 # If the server issues a 401 response then resend the request,690 # with a custom `X-Authentication` header.691 request.headers['X-Authentication'] = self.token692 yield request693```694695Custom authentication classes are designed to not perform any I/O, so that they may be used with both sync and async client instances. If you are implementing an authentication scheme that requires the request body, then you need to indicate this on the class using a `requires_request_body` property.696697You will then be able to access `request.content` inside the `.auth_flow()` method.698699```python700class MyCustomAuth(httpx.Auth):701 requires_request_body = True702703 def __init__(self, token):704 self.token = token705706 def auth_flow(self, request):707 response = yield request708 if response.status_code == 401:709 # If the server issues a 401 response then resend the request,710 # with a custom `X-Authentication` header.711 request.headers['X-Authentication'] = self.sign_request(...)712 yield request713714 def sign_request(self, request):715 # Create a request signature, based on `request.method`, `request.url`,716 # `request.headers`, and `request.content`.717 ...718```719720Similarly, if you are implementing a scheme that requires access to the response body, then use the `requires_response_body` property. You will then be able to access response body properties and methods such as `response.content`, `response.text`, `response.json()`, etc.721722```python723class MyCustomAuth(httpx.Auth):724 requires_response_body = True725726 def __init__(self, access_token, refresh_token, refresh_url):727 self.access_token = access_token728 self.refresh_token = refresh_token729 self.refresh_url = refresh_url730731 def auth_flow(self, request):732 request.headers["X-Authentication"] = self.access_token733 response = yield request734735 if response.status_code == 401:736 # If the server issues a 401 response, then issue a request to737 # refresh tokens, and resend the request.738 refresh_response = yield self.build_refresh_request()739 self.update_tokens(refresh_response)740741 request.headers["X-Authentication"] = self.access_token742 yield request743744 def build_refresh_request(self):745 # Return an `httpx.Request` for refreshing tokens.746 ...747748 def update_tokens(self, response):749 # Update the `.access_token` and `.refresh_token` tokens750 # based on a refresh response.751 data = response.json()752 ...753```754

Add support for sync-specific or async-specific auth flows (#1217)Florimond Mancabefore adoption016e4ee

lines 755–803why, one step back
755If you _do_ need to perform I/O other than HTTP requests, such as accessing a disk-based cache, or you need to use concurrency primitives, such as locks, then you should override `.sync_auth_flow()` and `.async_auth_flow()` (instead of `.auth_flow()`). The former will be used by `httpx.Client`, while the latter will be used by `httpx.AsyncClient`.
756757```python758import asyncio759import threading760import httpx761762763class MyCustomAuth(httpx.Auth):764 def __init__(self):765 self._sync_lock = threading.RLock()766 self._async_lock = asyncio.Lock()767768 def sync_get_token(self):769 with self._sync_lock:770 ...771772 def sync_auth_flow(self, request):773 token = self.sync_get_token()774 request.headers["Authorization"] = f"Token {token}"775 yield request776777 async def async_get_token(self):778 async with self._async_lock:779 ...780781 async def async_auth_flow(self, request):782 token = await self.async_get_token()783 request.headers["Authorization"] = f"Token {token}"784 yield request785```786787If you only want to support one of the two methods, then you should still override it, but raise an explicit `RuntimeError`.788789```python790import httpx791import sync_only_library792793794class MyCustomAuth(httpx.Auth):795 def sync_auth_flow(self, request):796 token = sync_only_library.get_token(...)797 request.headers["Authorization"] = f"Token {token}"798 yield request799800 async def async_auth_flow(self, request):801 raise RuntimeError("Cannot use a sync authentication class with httpx.AsyncClient")802```803

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 804–819why, one step back
804## SSL certificates
805806When making a request over HTTPS, HTTPX needs to verify the identity of the requested host. To do this, it uses a bundle of SSL certificates (a.k.a. CA bundle) delivered by a trusted certificate authority (CA).807808### Changing the verification defaults809810By default, HTTPX uses the CA bundle provided by [Certifi](https://pypi.org/project/certifi/). This is what you want in most cases, even though some advanced situations may require you to use a different set of certificates.811812If you'd like to use a custom CA bundle, you can use the `verify` parameter.813814```python815import httpx816817r = httpx.get("https://example.org", verify="path/to/client.pem")818```819

Document pool_limits and SSL context on verify (#942)Yeray Diaz Diazbefore adoption790a3ea

lines 820–821why, one step back
820Alternatively, you can pass a standard library `ssl.SSLContext`.
821

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 822why, one step back
822```pycon

Document pool_limits and SSL context on verify (#942)Yeray Diaz Diazbefore adoption790a3ea

lines 823–830why, one step back
823>>> import ssl
824>>> import httpx825>>> context = ssl.create_default_context()826>>> context.load_verify_locations(cafile="/tmp/client.pem")827>>> httpx.get('https://example.org', verify=context)828<Response [200 OK]>829```830

Included create_ssl_context function to create the same context with SSLConfig and serve as API (#996)Can Sarıgölbefore adoption926a55a

lines 831–832why, one step back
831We also include a helper function for creating properly configured `SSLContext` instances.
832

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 833why, one step back
833```pycon

Included create_ssl_context function to create the same context with SSLConfig and serve as API (#996)Can Sarıgölbefore adoption926a55a

lines 834–836why, one step back
834>>> context = httpx.create_ssl_context()
835```836

Advanced transport docs (#1165)Tom Christiebefore adoption477824a

lines 837–838why, one step back
837The `create_ssl_context` function accepts the same set of SSL configuration arguments
838(`trust_env`, `verify`, `cert` and `http2` arguments)

Included create_ssl_context function to create the same context with SSLConfig and serve as API (#996)Can Sarıgölbefore adoption926a55a

lines 839–840why, one step back
839as `httpx.Client` or `httpx.AsyncClient`
840

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 841why, one step back
841```pycon

Included create_ssl_context function to create the same context with SSLConfig and serve as API (#996)Can Sarıgölbefore adoption926a55a

lines 842–847why, one step back
842>>> import httpx
843>>> context = httpx.create_ssl_context(verify="/tmp/client.pem")844>>> httpx.get('https://example.org', verify=context)845<Response [200 OK]>846```847

Document pool_limits and SSL context on verify (#942)Yeray Diaz Diazbefore adoption790a3ea

line 848why, one step back
848Or you can also disable the SSL verification entirely, which is _not_ recommended.

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 849–875why, one step back
849
850```python851import httpx852853r = httpx.get("https://example.org", verify=False)854```855856### SSL configuration on client instances857858If you're using a `Client()` instance, then you should pass any SSL settings when instantiating the client.859860```python861client = httpx.Client(verify=False)862```863864The `client.get(...)` method and other request methods *do not* support changing the SSL settings on a per-request basis. If you need different SSL settings in different cases you should use more that one client instance, with different settings on each. Each client will then be using an isolated connection pool with a specific fixed SSL configuration on all connections within that pool.865866### Making HTTPS requests to a local server867868When making requests to local servers, such as a development server running on `localhost`, you will typically be using unencrypted HTTP connections.869870If you do need to make HTTPS connections to a local server, for example to test an HTTPS-only service, you will need to create and use your own certificates. Here's one way to do it:8718721. Use [trustme-cli](https://github.com/sethmlarson/trustme-cli/) to generate a pair of server key/cert files, and a client cert file.8731. Pass the server key/cert files when starting your local server. (This depends on the particular web server you're using. For example, [Uvicorn](https://www.uvicorn.org) provides the `--ssl-keyfile` and `--ssl-certfile` options.)8741. Tell HTTPX to use the certificates stored in `client.pem`:875

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 876why, one step back
876```pycon

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

lines 877–880why, one step back
877>>> import httpx
878>>> r = httpx.get("https://localhost:8000", verify="/tmp/client.pem")879>>> r880Response <200 OK>

Transport API (#963)Yeray Diaz Diazbefore adoptiond2816c9

lines 881–888why, one step back
881```
882883## Custom Transports884885HTTPX's `Client` also accepts a `transport` argument. This argument allows you886to provide a custom Transport object that will be used to perform the actual887sending of the requests.888

Drop urllib3 in favor of public gist (#1182)Florimond Mancabefore adoption8fa8765

lines 889–890why, one step back
889### Usage
890

Advanced transport docs (#1165)Tom Christiebefore adoption477824a

lines 891–894why, one step back
891For some advanced configuration you might need to instantiate a transport
892class directly, and pass it to the client instance. The `httpcore` package893provides a `local_address` configuration that is only available via this894low-level API.

Transport API (#963)Yeray Diaz Diazbefore adoptiond2816c9

line 895why, one step back
895

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 896why, one step back
896```pycon

Advanced transport docs (#1165)Tom Christiebefore adoption477824a

lines 897–908why, one step back
897>>> import httpx, httpcore
898>>> ssl_context = httpx.create_ssl_context()899>>> transport = httpcore.SyncConnectionPool(900... ssl_context=ssl_context,901... max_connections=100,902... max_keepalive_connections=20,903... keepalive_expiry=5.0,904... local_address="0.0.0.0"905... ) # Use the standard HTTPX defaults, but with an IPv4 only 'local_address'.906>>> client = httpx.Client(transport=transport)907```908

Document Unix Domain Socket usage (#1186)Florimond Mancabefore adoption34ba0e1

lines 909–926why, one step back
909Similarly, `httpcore` provides a `uds` option for connecting via a Unix Domain Socket that is only available via this low-level API:
910911```python912>>> import httpx, httpcore913>>> ssl_context = httpx.create_ssl_context()914>>> transport = httpcore.SyncConnectionPool(915... ssl_context=ssl_context,916... max_connections=100,917... max_keepalive_connections=20,918... keepalive_expiry=5.0,919... uds="/var/run/docker.sock",920... ) # Connect to the Docker API via a Unix Socket.921>>> client = httpx.Client(transport=transport)922>>> response = client.get("http://docker/info")923>>> response.json()924{"ID": "...", "Containers": 4, "Images": 74, ...}925```926

Advanced transport docs (#1165)Tom Christiebefore adoption477824a

lines 927–931why, one step back
927Unlike the `httpx.Client()`, the lower-level `httpcore` transport instances
928do not include any default values for configuring aspects such as the929connection pooling details, so you'll need to provide more explicit930configuration when using this API.931

Drop urllib3 in favor of public gist (#1182)Florimond Mancabefore adoption8fa8765

line 932why, one step back
932### urllib3 transport

Transport API (#963)Yeray Diaz Diazbefore adoptiond2816c9

line 933why, one step back
933

Drop urllib3 in favor of public gist (#1182)Florimond Mancabefore adoption8fa8765

lines 934–935why, one step back
934This [public gist](https://gist.github.com/florimondmanca/d56764d78d748eb9f73165da388e546e) provides a transport that uses the excellent [`urllib3` library](https://urllib3.readthedocs.io/en/latest/), and can be used with the sync `Client`...
935

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 936why, one step back
936```pycon

Transport API (#963)Yeray Diaz Diazbefore adoptiond2816c9

line 937why, one step back
937>>> import httpx

Drop urllib3 in favor of public gist (#1182)Florimond Mancabefore adoption8fa8765

lines 938–939why, one step back
938>>> from urllib3_transport import URLLib3Transport
939>>> client = httpx.Client(transport=URLLib3Transport())

Transport API (#963)Yeray Diaz Diazbefore adoptiond2816c9

lines 940–943why, one step back
940>>> client.get("https://example.org")
941<Response [200 OK]>942```943

Drop urllib3 in favor of public gist (#1182)Florimond Mancabefore adoption8fa8765

line 944why, one step back
944### Writing custom transports

Update dependencies in docs (#969)Tom Christiebefore adoption99a5c78

line 945why, one step back
945

Advanced transport docs (#1165)Tom Christiebefore adoption477824a

lines 946–951why, one step back
946A transport instance must implement the Transport API defined by
947[`httpcore`](https://www.encode.io/httpcore/api/). You948should either subclass `httpcore.AsyncHTTPTransport` to implement a transport to949use with `AsyncClient`, or subclass `httpcore.SyncHTTPTransport` to implement a950transport to use with `Client`.951

Update dependencies in docs (#969)Tom Christiebefore adoption99a5c78

line 952why, one step back
952A complete example of a custom transport implementation would be:

Transport API (#963)Yeray Diaz Diazbefore adoptiond2816c9

lines 953–958why, one step back
953
954```python955import json956import httpcore957958

Advanced transport docs (#1165)Tom Christiebefore adoption477824a

line 959why, one step back
959class HelloWorldTransport(httpcore.SyncHTTPTransport):

Transport API (#963)Yeray Diaz Diazbefore adoptiond2816c9

line 960why, one step back
960 """

Advanced transport docs (#1165)Tom Christiebefore adoption477824a

line 961why, one step back
961 A mock transport that always returns a JSON "Hello, world!" response.

Transport API (#963)Yeray Diaz Diazbefore adoptiond2816c9

lines 962–964why, one step back
962 """
963964 def request(self, method, url, headers=None, stream=None, timeout=None):

Advanced transport docs (#1165)Tom Christiebefore adoption477824a

lines 965–967why, one step back
965 message = {"text": "Hello, world!"}
966 content = json.dumps(message).encode("utf-8")967 stream = httpcore.PlainByteStream(content)

Transport API (#963)Yeray Diaz Diazbefore adoptiond2816c9

lines 968–973why, one step back
968 headers = [(b"content-type", b"application/json")]
969 return b"HTTP/1.1", 200, b"OK", headers, stream970```971972Which we can use in the same way:973

Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd

line 974why, one step back
974```pycon

Advanced transport docs (#1165)Tom Christiebefore adoption477824a

lines 975–977why, one step back
975>>> import httpx
976>>> client = httpx.Client(transport=HelloWorldTransport())977>>> response = client.get("https://example.org/")

Transport API (#963)Yeray Diaz Diazbefore adoptiond2816c9

line 978why, one step back
978>>> response.json()

Advanced transport docs (#1165)Tom Christiebefore adoption477824a

line 979why, one step back
979{"text": "Hello, world!"}

Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc

line 980why, one step back
980```