Skip to content

[HttpClient] add note about getInfo(debug) #11632

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 2 commits into from
May 31, 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
32 changes: 22 additions & 10 deletions components/http_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ following methods::
// you can get individual info too
$startTime = $response->getInfo('start_time');

.. tip::

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be an empty line between the start of the directive (.. tip::) and its content.


.. _http-client-streaming-responses:

Streaming Responses
Expand Down Expand Up @@ -316,17 +320,25 @@ When the HTTP status code of the response is in the 300-599 range (i.e. 3xx,
Caching Requests and Responses
------------------------------

This component provides a special HTTP client via the
:class:`Symfony\\Component\\HttpClient\\CachingHttpClient` class to cache
requests and their responses. The actual HTTP caching is implemented using the
:doc:`HttpKernel component </components/http_kernel>`, so make sure it's
installed in your application.
This component provides a :class:`Symfony\\Component\\HttpClient\\CachingHttpClient`
decorator that allows caching responses and serving them from the local storage
for next requests. The implementation leverages the
:class:`Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache` class under the hood
so that the :doc:`HttpKernel component </components/http_kernel>` needs to be
installed in your application::

..
.. TODO:
.. Show some example of caching requests+responses
..
..
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpClient\CachingHttpClient;
use Symfony\Component\HttpKernel\HttpCache\Store;

$store = new Store('/path/to/cache/storage/');
$client = HttpClient::create();
$client = new CachingHttpClient($client, $store);

// this won't hit the network if the resource is already in the cache
$response = $client->request('GET', 'https://example.com/cacheable-resource');

``CachingHttpClient`` accepts a third argument to set the options of the ``HttpCache``.

Scoping Client
--------------
Expand Down