Updates compatibility guide to address event hooks (#1436)

* 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:
https://github.com/encode/httpx/issues/1343#issuecomment-703223097

* Apply suggestions from code review

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
This commit is contained in:
Colton Eakins 2020-12-23 13:09:43 -06:00 committed by GitHub
parent 3c89b91d6b
commit e3a7b6d731
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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).