From: Colton Eakins Date: Wed, 23 Dec 2020 19:09:43 +0000 (-0600) Subject: Updates compatibility guide to address event hooks (#1436) X-Git-Tag: 0.17.0~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3a7b6d7318f943b2289437f74028cb36b5b02e4;p=thirdparty%2Fhttpx.git 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 Co-authored-by: Florimond Manca --- diff --git a/docs/compatibility.md b/docs/compatibility.md index 56476711..c8a074e4 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -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).