Skip to content
Myr

compatibility.md

This file

Path

docs/compatibility.md

39 lines · 1.7 KiB · Markdown

Last changed by

Add Response.is_error (#574)Tom Christiebefore adoptionfdaa012

History of this file

Take it

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

Explicitly check is_redirect in simple test case (#208)Tammo Behrendsbefore adoptionbebedcb

lines 1–8why, one step back
1# Requests Compatibility Guide
23HTTPX aims to be compatible with the `requests` API wherever possible.45This documentation outlines places where the API differs...67## QuickStart8

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

Explicitly check is_redirect in simple test case (#208)Tammo Behrendsbefore adoptionbebedcb

lines 10–15why, 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.13* `httpx.codes` - In our documentation we prefer the uppercased versions, such as `codes.NOT_FOUND`,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.

Add Response.is_error (#574)Tom Christiebefore adoptionfdaa012

line 17why, one step back
17* We don't support `response.is_ok` since the naming is ambiguous there, and might incorrectly imply an equivalence to `response.status_code == codes.OK`. Instead we provide an `.is_error` property.

Explicitly check is_redirect in simple test case (#208)Tammo Behrendsbefore adoptionbebedcb

lines 18–20why, one step back
18
19## Advanced Usage20

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

line 21why, one step back
21### requests.Session

Drop sync (#544)Tom Christiebefore adoption206c537

line 22why, one step back
22

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

lines 23–28why, one step back
23The HTTPX equivalent of `requests.Session` is `httpx.Client`.
2425```python26session = requests.Session(**kwargs)27```28

Drop sync (#544)Tom Christiebefore adoption206c537

line 29why, one step back
29is generally equivalent to

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

lines 30–31why, one step back
30
31```python

Drop sync (#544)Tom Christiebefore adoption206c537

line 32why, one step back
32client = httpx.Client(**kwargs)

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

lines 33–35why, one step back
33```
3435More detailed documentation and usage of `Client` can be found in [Advanced Usage](advanced.md).

Document mocking compatibility (#537)Jonas Lundbergbefore adoption2dbcaf8

lines 36–39why, one step back
36
37## Mocking3839If you need to mock HTTPX the same way that test utilities like `responses` and `requests-mock` does for `requests`, see [RESPX](https://github.com/lundberg/respx).