]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Mention default timeout differences from Requests in compatibility docs (#2433)
authorFrantišek Nesveda <fnesveda@users.noreply.github.com>
Mon, 7 Nov 2022 14:25:49 +0000 (15:25 +0100)
committerGitHub <noreply@github.com>
Mon, 7 Nov 2022 14:25:49 +0000 (15:25 +0100)
I was recently migrating a project from Requests to HTTPX, and I stumbled a bit on the default socket timeouts being different between the two, which I haven't seen explicitly mentioned anywhere.

This adds a mention of those differences to the compatibility section, feel free to edit it or move it around as you choose.

docs/compatibility.md

index 2a9cbd85efa7f1583a590e9651ddb698f62094b6..de8f701702bbac08e49d27094dd5e754c57556c3 100644 (file)
@@ -145,6 +145,16 @@ Within a `stream()` block request data is made available with:
 * `.iter_raw()` - Use this instead of `response.raw`
 * `.read()` - Read the entire response body, making `request.text` and `response.content` available.
 
+## Timeouts
+
+HTTPX defaults to including reasonable [timeouts](quickstart.md#timeouts) for all network operations, while Requests has no timeouts by default.
+
+To get the same behavior as Requests, set the `timeout` parameter to `None`:
+
+```python
+httpx.get('https://www.example.com', timeout=None)
+```
+
 ## Proxy keys
 
 When using `httpx.Client(proxies={...})` to map to a selection of different proxies, we use full URL schemes, such as `proxies={"http://": ..., "https://": ...}`.