@@ -738,7 +738,7 @@ original HTTP client::
738738
739739 $client = new RetryableHttpClient(HttpClient::create());
740740
741- The `` RetryableHttpClient ` ` uses a
741+ The :class: ` Symfony \\ Component \\ HttpClient \\ RetryableHttpClient ` uses a
742742:class: `Symfony\\ Component\\ HttpClient\\ Retry\\ RetryStrategyInterface ` to
743743decide if the request should be retried, and to define the waiting time between
744744each retry.
@@ -776,7 +776,8 @@ called when new data is uploaded or downloaded and at least once per second::
776776 ]);
777777
778778Any exceptions thrown from the callback will be wrapped in an instance of
779- ``TransportExceptionInterface `` and will abort the request.
779+ :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ TransportExceptionInterface `
780+ and will abort the request.
780781
781782HTTPS Certificates
782783~~~~~~~~~~~~~~~~~~
@@ -857,9 +858,10 @@ This component supports both the native PHP streams and cURL to make the HTTP
857858requests. Although both are interchangeable and provide the same features,
858859including concurrent requests, HTTP/2 is only supported when using cURL.
859860
860- ``HttpClient::create() `` selects the cURL transport if the `cURL PHP extension `_
861- is enabled and falls back to PHP streams otherwise. If you prefer to select
862- the transport explicitly, use the following classes to create the client::
861+ The :method: `Symfony\\ Component\\ HttpClient\\ HttpClient::create ` method
862+ selects the cURL transport if the `cURL PHP extension `_ is enabled and falls
863+ back to PHP streams otherwise. If you prefer to select the transport
864+ explicitly, use the following classes to create the client::
863865
864866 use Symfony\Component\HttpClient\CurlHttpClient;
865867 use Symfony\Component\HttpClient\NativeHttpClient;
@@ -1040,8 +1042,9 @@ following methods::
10401042Streaming Responses
10411043~~~~~~~~~~~~~~~~~~~
10421044
1043- Call the ``stream() `` method of the HTTP client to get *chunks * of the
1044- response sequentially instead of waiting for the entire response::
1045+ Call the :method: `Symfony\\ Contracts\\ HttpClient\\ HttpClientInterface::stream `
1046+ method to get *chunks * of the response sequentially instead of waiting for the
1047+ entire response::
10451048
10461049 $url = 'https://releases.ubuntu.com/18.04.1/ubuntu-18.04.1-desktop-amd64.iso';
10471050 $response = $client->request('GET', $url);
@@ -1071,8 +1074,7 @@ Canceling Responses
10711074
10721075To abort a request (e.g. because it didn't complete in due time, or you want to
10731076fetch only the first bytes of the response, etc.), you can either use the
1074- ``cancel() `` method of
1075- :class: `Symfony\\ Contracts\\ HttpClient\\ ResponseInterface `::
1077+ :method: `Symfony\\ Contracts\\ HttpClient\\ ResponseInterface::cancel `::
10761078
10771079 $response->cancel();
10781080
@@ -1190,10 +1192,12 @@ If you look again at the snippet above, responses are read in requests' order.
11901192But maybe the 2nd response came back before the 1st? Fully asynchronous operations
11911193require being able to deal with the responses in whatever order they come back.
11921194
1193- In order to do so, the ``stream() `` method of HTTP clients accepts a list of
1194- responses to monitor. As mentioned :ref: `previously <http-client-streaming-responses >`,
1195- this method yields response chunks as they arrive from the network. By replacing
1196- the "foreach" in the snippet with this one, the code becomes fully async::
1195+ In order to do so, the
1196+ :method: `Symfony\\ Contracts\\ HttpClient\\ HttpClientInterface::stream `
1197+ accepts a list of responses to monitor. As mentioned
1198+ :ref: `previously <http-client-streaming-responses >`, this method yields response
1199+ chunks as they arrive from the network. By replacing the "foreach" in the
1200+ snippet with this one, the code becomes fully async::
11971201
11981202 foreach ($client->stream($responses) as $response => $chunk) {
11991203 if ($chunk->isFirst()) {
@@ -1330,7 +1334,8 @@ installed in your application::
13301334 // this won't hit the network if the resource is already in the cache
13311335 $response = $client->request('GET', 'https://example.com/cacheable-resource');
13321336
1333- ``CachingHttpClient `` accepts a third argument to set the options of the ``HttpCache ``.
1337+ :class: `Symfony\\ Component\\ HttpClient\\ CachingHttpClient` ` accepts a third argument
1338+ to set the options of the :class: `Symfony\\ Component\\ HttpKernel\\ HttpCache\\ HttpCache `.
13341339
13351340Consuming Server-Sent Events
13361341----------------------------
@@ -1496,8 +1501,8 @@ it. As such, you should not use it in newly written code. The component is still
14961501interoperable with libraries that require it thanks to the
14971502:class: `Symfony\\ Component\\ HttpClient\\ HttplugClient ` class. Similarly to
14981503:class: `Symfony\\ Component\\ HttpClient\\ Psr18Client ` implementing relevant parts of PSR-17,
1499- `` HttplugClient `` also implements the factory methods defined in the related
1500- ``php-http/message-factory `` package.
1504+ :class: ` Symfony \\ Component \\ HttpClient \\ HttplugClient ` also implements the factory methods
1505+ defined in the related ``php-http/message-factory `` package.
15011506
15021507.. code-block :: terminal
15031508
@@ -1528,15 +1533,16 @@ that requires HTTPlug dependencies::
15281533 // [...]
15291534 }
15301535
1531- Because ``HttplugClient `` implements the three interfaces, you can use it this way::
1536+ Because :class: `Symfony\\ Component\\ HttpClient\\ HttplugClient ` implements the
1537+ three interfaces,you can use it this way::
15321538
15331539 use Symfony\Component\HttpClient\HttplugClient;
15341540
15351541 $httpClient = new HttplugClient();
15361542 $apiClient = new SomeSdk($httpClient, $httpClient, $httpClient);
15371543
1538- If you'd like to work with promises, `` HttplugClient `` also implements the
1539- ``HttpAsyncClient `` interface. To use it, you need to install the
1544+ If you'd like to work with promises, :class: ` Symfony \\ Component \\ HttpClient \\ HttplugClient `
1545+ also implements the ``HttpAsyncClient `` interface. To use it, you need to install the
15401546``guzzlehttp/promises `` package:
15411547
15421548.. code-block :: terminal
@@ -1716,20 +1722,24 @@ external service. By not making actual HTTP requests there is no need to worry a
17161722the service being online or the request changing state, for example deleting
17171723a resource.
17181724
1719- ``MockHttpClient `` implements the ``HttpClientInterface ``, just like any actual
1720- HTTP client in this component. When you type-hint with ``HttpClientInterface ``
1721- your code will accept the real client outside tests, while replacing it with
1722- ``MockHttpClient `` in the test.
1725+ :class: `Symfony\\ Component\\ HttpClient\\ MockHttpClient ` implements the
1726+ :class: `Symfony\\ Contracts\\ HttpClient\\ HttpClientInterface `, just like any actual
1727+ HTTP client in this component. When you type-hint with
1728+ :class: `Symfony\\ Contracts\\ HttpClient\\ HttpClientInterface ` your code will accept
1729+ the real client outside tests, while replacing it with
1730+ :class: `Symfony\\ Component\\ HttpClient\\ MockHttpClient ` in the test.
17231731
1724- When the ``request `` method is used on ``MockHttpClient ``, it will respond with
1725- the supplied ``MockResponse ``. There are a few ways to use it, as described
1726- below.
1732+ When the ``request `` method is used on :class: `Symfony\\ Component\\ HttpClient\\ MockHttpClient `,
1733+ it will respond with the supplied
1734+ :class: `Symfony\\ Component\\ HttpClient\\ Response\\ MockResponse `. There are a few ways to use
1735+ it, as described below.
17271736
17281737HTTP Client and Responses
17291738~~~~~~~~~~~~~~~~~~~~~~~~~
17301739
1731- The first way of using ``MockHttpClient `` is to pass a list of responses to its
1732- constructor. These will be yielded in order when requests are made::
1740+ The first way of using :class: `Symfony\\ Component\\ HttpClient\\ MockHttpClient `
1741+ is to pass a list of responses to its constructor. These will be yielded
1742+ in order when requests are made::
17331743
17341744 use Symfony\Component\HttpClient\MockHttpClient;
17351745 use Symfony\Component\HttpClient\Response\MockResponse;
@@ -1744,8 +1754,8 @@ constructor. These will be yielded in order when requests are made::
17441754 $response1 = $client->request('...'); // returns $responses[0]
17451755 $response2 = $client->request('...'); // returns $responses[1]
17461756
1747- Another way of using `` MockHttpClient `` is to pass a callback that generates the
1748- responses dynamically when it's called::
1757+ Another way of using :class: ` Symfony \\ Component \\ HttpClient \\ MockHttpClient ` is to
1758+ pass a callback that generates the responses dynamically when it's called::
17491759
17501760 use Symfony\Component\HttpClient\MockHttpClient;
17511761 use Symfony\Component\HttpClient\Response\MockResponse;
@@ -1787,7 +1797,9 @@ assertions on the request before returning the mocked response::
17871797.. tip ::
17881798
17891799 Instead of using the first argument, you can also set the (list of)
1790- responses or callbacks using the ``setResponseFactory() `` method::
1800+ responses or callbacks using the
1801+ :method: `Symfony\\ Component\\ HttpClient\\ MockHttpClient::setResponseFactory `
1802+ method::
17911803
17921804 $responses = [
17931805 new MockResponse($body1, $info1),
@@ -1799,7 +1811,8 @@ assertions on the request before returning the mocked response::
17991811
18001812 .. versionadded :: 5.4
18011813
1802- The ``setResponseFactory() `` method was introduced in Symfony 5.4.
1814+ The :method: `Symfony\\ Component\\ HttpClient\\ MockHttpClient::setResponseFactory `
1815+ method was introduced in Symfony 5.4.
18031816
18041817If you need to test responses with HTTP status codes different than 200,
18051818define the ``http_code `` option::
@@ -1815,10 +1828,12 @@ define the ``http_code`` option::
18151828 $response = $client->request('...');
18161829
18171830The responses provided to the mock client don't have to be instances of
1818- ``MockResponse ``. Any class implementing ``ResponseInterface `` will work (e.g.
1819- ``$this->createMock(ResponseInterface::class) ``).
1831+ :class: `Symfony\\ Component\\ HttpClient\\ Response\\ MockResponse `. Any class
1832+ implementing :class: `Symfony\\ Contracts\\ HttpClient\\ ResponseInterface `
1833+ will work (e.g. ``$this->createMock(ResponseInterface::class) ``).
18201834
1821- However, using ``MockResponse `` allows simulating chunked responses and timeouts::
1835+ However, using :class: `Symfony\\ Component\\ HttpClient\\ Response\\ MockResponse `
1836+ allows simulating chunked responses and timeouts::
18221837
18231838 $body = function () {
18241839 yield 'hello';
@@ -1910,7 +1925,8 @@ Then configure Symfony to use your callback:
19101925 Testing Request Data
19111926~~~~~~~~~~~~~~~~~~~~
19121927
1913- The ``MockResponse `` class comes with some helper methods to test the request:
1928+ The :class: `Symfony\\ Component\\ HttpClient\\ Response\\ MockResponse ` class comes
1929+ with some helper methods to test the request:
19141930
19151931* ``getRequestMethod() `` - returns the HTTP method;
19161932* ``getRequestUrl() `` - returns the URL the request would be sent to;
@@ -1919,8 +1935,9 @@ The ``MockResponse`` class comes with some helper methods to test the request:
19191935
19201936.. versionadded :: 5.2
19211937
1922- The ``getRequestMethod() `` and ``getRequestUrl() `` methods were introduced
1923- in Symfony 5.2.
1938+ The :method: `Symfony\\ Component\\ HttpClient\\ Response\\ MockResponse::getRequestMethod `
1939+ and :method: `Symfony\\ Component\\ HttpClient\\ Response\\ MockResponse::getRequestUrl `
1940+ methods were introduced in Symfony 5.2.
19241941
19251942Usage example::
19261943
0 commit comments