]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Updates compatibility guide to address event hooks (#1436)
authorColton Eakins <coltoneakins@gmail.com>
Wed, 23 Dec 2020 19:09:43 +0000 (13:09 -0600)
committerGitHub <noreply@github.com>
Wed, 23 Dec 2020 19:09:43 +0000 (20:09 +0100)
* 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>
docs/compatibility.md

index 564767118bf6c1258af6741c59a609f196e25004..c8a074e4918a23360780565b1c6e9b231fbacd4c 100644 (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).