From ab7969ca24a0e63a562f9b96ca049bd4483b5b0b Mon Sep 17 00:00:00 2001 From: Benoit Galati Date: Sat, 8 Feb 2020 13:57:26 +0100 Subject: [PATCH] Document pre-conditions for HttpClient asynchronous behavior --- components/http_client.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/http_client.rst b/components/http_client.rst index 1217c6f8606..cd37dd860c8 100644 --- a/components/http_client.rst +++ b/components/http_client.rst @@ -116,6 +116,14 @@ immediately instead of waiting to receive the response:: This component also supports :ref:`streaming responses ` for full asynchronous applications. +.. caution:: + + Reference to ``$response`` object must be kept in order to benefit from the asynchronous + behavior. If not, the response object is destroyed by PHP + garbage collector which forces the response to be resolved at this moment. + One solution is to store all ``$response`` object in an ``array`` to keep a reference to them + until they are not needed anymore. + .. note:: HTTP compression and chunked transfer encoding are automatically enabled when