Skip to content

Mentioned the toStream() method #12355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions components/http_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ following methods::
// gets the response body as a string
$content = $response->getContent();

// casts the response JSON contents to a PHP array
$content = $response->toArray();

// casts the response content to a PHP stream resource
$content = $response->toStream();

// cancels the request/response
$response->cancel();

Expand All @@ -339,16 +345,19 @@ following methods::
// you can get individual info too
$startTime = $response->getInfo('start_time');

// returns detailed logs about the requests and responses of the HTTP transaction
$httpLogs = $response->getInfo('debug');

.. versionadded:: 4.4

The ``toStream()`` method was introduced in Symfony 4.4.

.. note::

``$response->getInfo()`` is non-blocking: it returns *live* information
about the response. Some of them might not be known yet (e.g. ``http_code``)
when you'll call it.

.. tip::

Call ``$response->getInfo('debug')`` to get detailed logs about the HTTP transaction.

.. _http-client-streaming-responses:

Streaming Responses
Expand Down