Skip to content

Commit 1484bce

Browse files
committed
Merge branch '4.4'
* 4.4: [HttpClient] Documented the cancel() method
2 parents 08d8df4 + ea04279 commit 1484bce

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

components/http_client.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,23 @@ the "foreach" in the snippet with this one, the code becomes fully async::
376376
Use the ``user_data`` option combined with ``$response->getInfo('user_data')``
377377
to track the identity of the responses in your foreach loops.
378378

379+
Canceling Responses
380+
~~~~~~~~~~~~~~~~~~~
381+
382+
Responses can be canceled at any moment before they are completed using the
383+
``cancel()`` method::
384+
385+
foreach ($client->stream($responses) as $response => $chunk) {
386+
// ...
387+
388+
// if some condition happens, cancel the response
389+
$response->cancel();
390+
}
391+
392+
.. versionadded:: 4.4
393+
394+
The ``cancel()`` method was introduced in Symfony 4.4.
395+
379396
Dealing with Network Timeouts
380397
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
381398

0 commit comments

Comments
 (0)