Skip to content

Commit

Permalink
Updates compatibility guide to address event hooks (encode#1436)
Browse files Browse the repository at this point in the history
* Updates compatibility guide to address event hooks

In `requests`, event hook callbacks can mutate response/request objects. In HTTPX, this is not the case.
Added text to address this difference, and added a link to the best alternate HTTPX offers in this circumstance.
 
More context:
encode#1343 (comment)

* Apply suggestions from code review

Co-authored-by: Florimond Manca <[email protected]>

Co-authored-by: Florimond Manca <[email protected]>
  • Loading branch information
coltoneakins and florimondmanca authored Dec 23, 2020
1 parent 3c89b91 commit e3a7b6d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,11 @@ while request is not None:
response = client.send(request, allow_redirects=False)
request = response.next_request
```

## Event Hooks

`requests` allows event hooks to mutate `Request` and `Response` objects. See [examples](https://requests.readthedocs.io/en/master/user/advanced/#event-hooks) given in the documentation for `requests`.

In HTTPX, event hooks may access properties of requests and responses, but event hook callbacks cannot mutate the original request/response.

If you are looking for more control, consider checking out [Custom Transports](advanced.md#custom-transports).

0 comments on commit e3a7b6d

Please sign in to comment.