File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -303,6 +303,29 @@ response sequentially instead of waiting for the entire response::
303303 fwrite($fileHandler, $chunk->getContent());
304304 }
305305
306+ Canceling Responses
307+ ~~~~~~~~~~~~~~~~~~~
308+
309+ To abort a request (e.g. because it didn't answer in due time, or you want to
310+ fetch only the first bytes of the response, etc.), you can either:
311+
312+ * use the ``cancel() `` method of ``ResponseInterface ``::
313+
314+ $response->cancel()
315+
316+ * throw an exception from a progress callback::
317+
318+ $response = $client->request('GET', 'https://..;', [
319+ 'on_progress' => function (int $dlNow, int $dlSize, array $info): void {
320+ // ...
321+
322+ throw new \MyException();
323+ },
324+ ]);
325+
326+ The exception will be wrapped in a ``TransportExceptionInterface`` and will
327+ abort the request.
328+
306329Handling Exceptions
307330~~~~~~~~~~~~~~~~~~~
308331
You can’t perform that action at this time.
0 commit comments