Skip to content

Commit ea86ad7

Browse files
committed
Merge branch '5.4' into 6.2
* 5.4: [HttpClient] Replaced code block by `:class:` when relevant
2 parents cbce155 + a377f07 commit ea86ad7

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

http_client.rst

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,9 @@ SSRF (Server-side request forgery) Handling
774774
requests to an arbitrary domain. These attacks can also target the internal
775775
hosts and IPs of the attacked server.
776776

777-
If you use an ``HttpClient`` together with user-provided URIs, it is probably a
778-
good idea to decorate it with a ``NoPrivateNetworkHttpClient``. This will
777+
If you use an :class:`Symfony\\Component\\HttpClient\\HttpClient` together
778+
with user-provided URIs, it is probably a good idea to decorate it with a
779+
:class:`Symfony\\Component\\HttpClient\\NoPrivateNetworkHttpClient`. This will
779780
ensure local networks are made inaccessible to the HTTP client::
780781

781782
use Symfony\Component\HttpClient\HttpClient;
@@ -847,8 +848,8 @@ Configuring CurlHttpClient Options
847848

848849
PHP allows to configure lots of `cURL options`_ via the :phpfunction:`curl_setopt`
849850
function. In order to make the component more portable when not using cURL, the
850-
``CurlHttpClient`` only uses some of those options (and they are ignored in the
851-
rest of clients).
851+
:class:`Symfony\\Component\\HttpClient\\CurlHttpClient` only uses some of those
852+
options (and they are ignored in the rest of clients).
852853

853854
Add an ``extra.curl`` option in your configuration to pass those extra options::
854855

@@ -1029,7 +1030,8 @@ Canceling Responses
10291030

10301031
To abort a request (e.g. because it didn't complete in due time, or you want to
10311032
fetch only the first bytes of the response, etc.), you can either use the
1032-
``cancel()`` method of ``ResponseInterface``::
1033+
``cancel()`` method of
1034+
:class:`Symfony\\Contracts\\HttpClient\\ResponseInterface`::
10331035

10341036
$response->cancel();
10351037

@@ -1043,7 +1045,8 @@ Or throw an exception from a progress callback::
10431045
},
10441046
]);
10451047

1046-
The exception will be wrapped in an instance of ``TransportExceptionInterface``
1048+
The exception will be wrapped in an instance of
1049+
:class:`Symfony\\Contracts\\HttpClient\\Exception\\TransportExceptionInterface`
10471050
and will abort the request.
10481051

10491052
In case the response was canceled using ``$response->cancel()``,
@@ -1243,7 +1246,8 @@ that network errors can happen when calling e.g. ``getStatusCode()`` too::
12431246
Because ``$response->getInfo()`` is non-blocking, it shouldn't throw by design.
12441247

12451248
When multiplexing responses, you can deal with errors for individual streams by
1246-
catching ``TransportExceptionInterface`` in the foreach loop::
1249+
catching :class:`Symfony\\Contracts\\HttpClient\\Exception\\TransportExceptionInterface`
1250+
in the foreach loop::
12471251

12481252
foreach ($client->stream($responses) as $response => $chunk) {
12491253
try {
@@ -1383,9 +1387,9 @@ PSR-18 and PSR-17
13831387

13841388
This component implements the `PSR-18`_ (HTTP Client) specifications via the
13851389
:class:`Symfony\\Component\\HttpClient\\Psr18Client` class, which is an adapter
1386-
to turn a Symfony ``HttpClientInterface`` into a PSR-18 ``ClientInterface``.
1387-
This class also implements the relevant methods of `PSR-17`_ to ease creating
1388-
request objects.
1390+
to turn a Symfony :class:`Symfony\\Contracts\\HttpClient\\HttpClientInterface`
1391+
into a PSR-18 ``ClientInterface``. This class also implements the relevant
1392+
methods of `PSR-17`_ to ease creating request objects.
13891393

13901394
To use it, you need the ``psr/http-client`` package and a `PSR-17`_ implementation:
13911395

@@ -1467,9 +1471,9 @@ The `HTTPlug`_ v1 specification was published before PSR-18 and is superseded by
14671471
it. As such, you should not use it in newly written code. The component is still
14681472
interoperable with libraries that require it thanks to the
14691473
:class:`Symfony\\Component\\HttpClient\\HttplugClient` class. Similarly to
1470-
``Psr18Client`` implementing relevant parts of PSR-17, ``HttplugClient`` also
1471-
implements the factory methods defined in the related ``php-http/message-factory``
1472-
package.
1474+
:class:`Symfony\\Component\\HttpClient\\Psr18Client` implementing relevant parts of PSR-17,
1475+
``HttplugClient`` also implements the factory methods defined in the related
1476+
``php-http/message-factory`` package.
14731477

14741478
.. code-block:: terminal
14751479
@@ -1691,15 +1695,20 @@ has many safety checks that will throw a ``LogicException`` if the chunk
16911695
passthru doesn't behave correctly; e.g. if a chunk is yielded after an ``isLast()``
16921696
one, or if a content chunk is yielded before an ``isFirst()`` one, etc.
16931697

1698+
.. versionadded:: 5.2
1699+
1700+
:class:`Symfony\\Component\\HttpClient\\AsyncDecoratorTrait` was introduced in Symfony 5.2.
1701+
16941702
Testing
16951703
-------
16961704

1697-
This component includes the ``MockHttpClient`` and ``MockResponse`` classes to
1698-
use in tests that shouldn't make actual HTTP requests. Such tests can be
1699-
useful, as they will run faster and produce consistent results, since they're
1700-
not dependent on an external service. By not making actual HTTP requests there
1701-
is no need to worry about the service being online or the request changing
1702-
state, for example deleting a resource.
1705+
This component includes the :class:`Symfony\\Component\\HttpClient\\MockHttpClient`
1706+
and :class:`Symfony\\Component\\HttpClient\\Response\\MockResponse` classes to use
1707+
in tests that shouldn't make actual HTTP requests. Such tests can be useful, as they
1708+
will run faster and produce consistent results, since they're not dependent on an
1709+
external service. By not making actual HTTP requests there is no need to worry about
1710+
the service being online or the request changing state, for example deleting
1711+
a resource.
17031712

17041713
``MockHttpClient`` implements the ``HttpClientInterface``, just like any actual
17051714
HTTP client in this component. When you type-hint with ``HttpClientInterface``

0 commit comments

Comments
 (0)