Skip to content

Commit 41dd55e

Browse files
committed
Minor tweaks
1 parent 689f71b commit 41dd55e

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

components/http_client.rst

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,17 @@ To abort a request (e.g. because it didn't complete in due time, or you want to
371371
fetch only the first bytes of the response, etc.), you can either use the
372372
``cancel()`` method of ``ResponseInterface``::
373373

374-
$response->cancel()
374+
$response->cancel()
375375

376376
Or throw an exception from a progress callback::
377377

378-
$response = $client->request('GET', 'https://...', [
378+
$response = $client->request('GET', 'https://...', [
379379
'on_progress' => function (int $dlNow, int $dlSize, array $info): void {
380380
// ...
381381

382382
throw new \MyException();
383383
},
384-
]);
384+
]);
385385

386386
The exception will be wrapped in an instance of ``TransportExceptionInterface``
387387
and will abort the request.
@@ -463,23 +463,6 @@ the "foreach" in the snippet with this one, the code becomes fully async::
463463
Use the ``user_data`` option combined with ``$response->getInfo('user_data')``
464464
to track the identity of the responses in your foreach loops.
465465

466-
Canceling Responses
467-
~~~~~~~~~~~~~~~~~~~
468-
469-
Responses can be canceled at any moment before they are completed using the
470-
``cancel()`` method::
471-
472-
foreach ($client->stream($responses) as $response => $chunk) {
473-
// ...
474-
475-
// if some condition happens, cancel the response
476-
$response->cancel();
477-
}
478-
479-
.. versionadded:: 4.4
480-
481-
The ``cancel()`` method was introduced in Symfony 4.4.
482-
483466
Dealing with Network Timeouts
484467
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
485468

0 commit comments

Comments
 (0)