Skip to content
Myr

compatibility.md

This file

Path

docs/compatibility.md

33 lines · 1.3 KiB · Markdown

Last changed by

Add documentation for requests.Session compatibility (#449)Jt Miclatbefore adoption31730e7

History of this file

Take it

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 1–2why, one step back
1# Requests Compatibility Guide
2

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 3why, one step back
3HTTPX aims to be compatible with the `requests` API wherever possible.

http3 (#86)Tom Christiebefore adoptionc9747aa

lines 4–6why, one step back
4
5This documentation outlines places where the API differs...6

Tweaks (#89)Tom Christiebefore adoption7c6fb5c

lines 7–8why, one step back
7## QuickStart
8

Fix typos, spelling issues, and grammar in docs (#426)Kyle Galbraithbefore adoptionb65bce5

line 9why, one step back
9Pretty much any API mentioned in the `requests` QuickStart should be identical

Tweaks (#89)Tom Christiebefore adoption7c6fb5c

lines 10–12why, one step back
10to the API in our own documentation. The following exceptions apply:
1112* `Response.url` - Returns a `URL` instance, rather than a string. Use `str(response.url)` if you need a string instance.

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 13why, one step back
13* `httpx.codes` - In our documentation we prefer the uppercased versions, such as `codes.NOT_FOUND`,

Tweaks (#89)Tom Christiebefore adoption7c6fb5c

lines 14–15why, one step back
14but also provide lower-cased versions for API compatibility with `requests`.
15* `stream=True`. - Streaming responses provide the `.stream()` and `.raw()` byte iterator interfaces, rather than the `.iter_content()` method and the `.raw` socket interface.

Document compatibility difference for get, delete, head, and options (#418)Jt Miclatbefore adoption85fa89c

line 16why, one step back
16* `.get`, `.delete`, `.head`, `.options` - These methods do not support `files`, `data`, or `json` arguments. Use `.request` if you need to need to send data using these http methods.

Tweaks (#89)Tom Christiebefore adoption7c6fb5c

lines 17–19why, one step back
17
18## Advanced Usage19

Add documentation for requests.Session compatibility (#449)Jt Miclatbefore adoption31730e7

lines 20–33why, one step back
20### requests.Session
21The HTTPX equivalent of `requests.Session` is `httpx.Client`.2223```python24session = requests.Session(**kwargs)25```2627is equivalent to2829```python30client = httpx.Client(**kwargs)31```3233More detailed documentation and usage of `Client` can be found in [Advanced Usage](advanced.md).