@@ -371,17 +371,17 @@ To abort a request (e.g. because it didn't complete in due time, or you want to
371
371
fetch only the first bytes of the response, etc.), you can either use the
372
372
``cancel() `` method of ``ResponseInterface ``::
373
373
374
- $response->cancel()
374
+ $response->cancel()
375
375
376
376
Or throw an exception from a progress callback::
377
377
378
- $response = $client->request('GET', 'https://...', [
378
+ $response = $client->request('GET', 'https://...', [
379
379
'on_progress' => function (int $dlNow, int $dlSize, array $info): void {
380
380
// ...
381
381
382
382
throw new \MyException();
383
383
},
384
- ]);
384
+ ]);
385
385
386
386
The exception will be wrapped in an instance of ``TransportExceptionInterface ``
387
387
and will abort the request.
@@ -463,23 +463,6 @@ the "foreach" in the snippet with this one, the code becomes fully async::
463
463
Use the ``user_data `` option combined with ``$response->getInfo('user_data') ``
464
464
to track the identity of the responses in your foreach loops.
465
465
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
-
483
466
Dealing with Network Timeouts
484
467
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
485
468
0 commit comments