compatibility.md
This file
Path
docs/compatibility.md
38 lines · 1.9 KiB · Markdown
Last changed by
Add Client.stream() method. (#600)Tom Christiebefore adoption8d8ea8b
History of this fileTake it
The walk stopped after 200 commits: lines older than 45177d2 point at it.
Rely on IRIReference.encode() for IDNA encoding (#210)Can Sarıgölbefore adoption45177d2
lines 1–8why, one step back1# Requests Compatibility Guide23HTTPX aims to be compatible with the `requests` API wherever possible.45This documentation outlines places where the API differs...67## QuickStart8Fix typos, spelling issues, and grammar in docs (#426)Kyle Galbraithbefore adoptionb65bce5
line 9why, one step back9Pretty much any API mentioned in the `requests` QuickStart should be identicalRely on IRIReference.encode() for IDNA encoding (#210)Can Sarıgölbefore adoption45177d2
lines 10–12why, one step back10to 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.Add Client.stream() method. (#600)Tom Christiebefore adoption8d8ea8b
lines 13–14why, one step back13* `httpx.codes` - In our documentation we prefer the uppercased versions, such as `codes.NOT_FOUND`, but also provide lower-cased versions for API compatibility with `requests`.14* `stream()`. - HTTPX provides a `.stream()` interface rather than using `stream=True`. This ensures that streaming responses are always properly closed outside of the stream block, and makes it visually clearer at which points streaming I/O APIs may be used with a response. Streaming request data is made avialable with `.stream_bytes()`, `.stream_text()`, `.stream_lines()`, and `.stream_raw()`.Document compatibility difference for get, delete, head, and options (#418)Jt Miclatbefore adoption85fa89c
line 15why, one step back15* `.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 Client.stream() method. (#600)Tom Christiebefore adoption8d8ea8b
line 16why, one step back16* 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 the `response.is_error` property. Use `if not response.is_error:` instead of `if response.is_ok:`.Rely on IRIReference.encode() for IDNA encoding (#210)Can Sarıgölbefore adoption45177d2
lines 17–19why, one step back1718## Advanced Usage19Add documentation for requests.Session compatibility (#449)Jt Miclatbefore adoption31730e7
line 20why, one step back20### requests.SessionDrop sync (#544)Tom Christiebefore adoption206c537
line 21why, one step back21Add documentation for requests.Session compatibility (#449)Jt Miclatbefore adoption31730e7
lines 22–27why, one step back22The HTTPX equivalent of `requests.Session` is `httpx.Client`.2324```python25session = requests.Session(**kwargs)26```27Drop sync (#544)Tom Christiebefore adoption206c537
line 28why, one step back28is generally equivalent toAdd documentation for requests.Session compatibility (#449)Jt Miclatbefore adoption31730e7
lines 29–30why, one step back2930```pythonDrop sync (#544)Tom Christiebefore adoption206c537
line 31why, one step back31client = httpx.Client(**kwargs)Add documentation for requests.Session compatibility (#449)Jt Miclatbefore adoption31730e7
lines 32–34why, one step back32```3334More detailed documentation and usage of `Client` can be found in [Advanced Usage](advanced.md).Document mocking compatibility (#537)Jonas Lundbergbefore adoption2dbcaf8
lines 35–38why, one step back3536## Mocking3738If 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).