Skip to content

Commit a40d6ab

Browse files
committed
Document pre-conditions for HttpClient asynchronous behavior
1 parent 015b177 commit a40d6ab

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

components/http_client.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ immediately instead of waiting to receive the response::
116116
This component also supports :ref:`streaming responses <http-client-streaming-responses>`
117117
for full asynchronous applications.
118118

119+
.. caution::
120+
121+
Reference to ``$response`` object must be kept in order to benefit from the asynchronous
122+
behavior. If no reference is kept the response object is destroyed by PHP
123+
garbage collector which force the response to be resolved at this moment.
124+
One solution is to store all ``$response`` object in an ``array`` to keep a reference to them
125+
until they are not needed anymore.
126+
119127
.. note::
120128

121129
HTTP compression and chunked transfer encoding are automatically enabled when

0 commit comments

Comments
 (0)