Skip to content

Commit 7ad8b60

Browse files
committed
Merge branch '6.2' into 6.3
* 6.2: [HttpClient] Replaced code block by `:class:` when relevant
2 parents 0f92bc4 + ea86ad7 commit 7ad8b60

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
@@ -775,8 +775,9 @@ SSRF (Server-side request forgery) Handling
775775
requests to an arbitrary domain. These attacks can also target the internal
776776
hosts and IPs of the attacked server.
777777

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

782783
use Symfony\Component\HttpClient\HttpClient;
@@ -848,8 +849,8 @@ Configuring CurlHttpClient Options
848849

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

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

@@ -1030,7 +1031,8 @@ Canceling Responses
10301031

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

10351037
$response->cancel();
10361038

@@ -1044,7 +1046,8 @@ Or throw an exception from a progress callback::
10441046
},
10451047
]);
10461048

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

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

12461249
When multiplexing responses, you can deal with errors for individual streams by
1247-
catching ``TransportExceptionInterface`` in the foreach loop::
1250+
catching :class:`Symfony\\Contracts\\HttpClient\\Exception\\TransportExceptionInterface`
1251+
in the foreach loop::
12481252

12491253
foreach ($client->stream($responses) as $response => $chunk) {
12501254
try {
@@ -1384,9 +1388,9 @@ PSR-18 and PSR-17
13841388

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)