diff --git a/en/appendices/5-1-upgrade-guide.rst b/en/appendices/5-1-upgrade-guide.rst index 1dd32a3942..b70348b34d 100644 --- a/en/appendices/5-1-upgrade-guide.rst +++ b/en/appendices/5-1-upgrade-guide.rst @@ -14,6 +14,9 @@ Http - ``SecurityHeadersMiddleware::setPermissionsPolicy()`` was added. This method adds the ability to define ``permissions-policy`` header values. +- ``Client`` now emits ``HttpClient.beforeSend`` and ``HttpClient.afterSend`` + events when requests are sent. You can use these events to perform logging, + caching or collect telemetry. Validation ---------- diff --git a/en/core-libraries/httpclient.rst b/en/core-libraries/httpclient.rst index cdb11bcc3b..514568a4be 100644 --- a/en/core-libraries/httpclient.rst +++ b/en/core-libraries/httpclient.rst @@ -358,6 +358,17 @@ method:: ]); $http->addCookie(new Cookie('session', 'abc123')); +Client Events +============= + +``Client`` will emit events when requests are sent. The +``HttpClient.beforeSend`` event is fired before a request is sent, and +``HttpClient.afterSend`` is fired after a request is sent. You can modify the +request, or set a response in a ``beforeSend`` listener. The ``afterSend`` event +is triggered for all requests, even those that have their responses set by +a ``beforeSend`` event. + + .. _httpclient-response-objects: Response Objects