@@ -790,8 +790,9 @@ SSRF (Server-side request forgery) Handling
790
790
requests to an arbitrary domain. These attacks can also target the internal
791
791
hosts and IPs of the attacked server.
792
792
793
- If you use an ``HttpClient `` together with user-provided URIs, it is probably a
794
- good idea to decorate it with a ``NoPrivateNetworkHttpClient ``. This will
793
+ If you use an :class: `Symfony\\ Component\\ HttpClient\\ HttpClient ` together
794
+ with user-provided URIs, it is probably a good idea to decorate it with a
795
+ :class: `Symfony\\ Component\\ HttpClient\\ NoPrivateNetworkHttpClient `. This will
795
796
ensure local networks are made inaccessible to the HTTP client::
796
797
797
798
use Symfony\Component\HttpClient\HttpClient;
@@ -871,8 +872,8 @@ Configuring CurlHttpClient Options
871
872
872
873
PHP allows to configure lots of `cURL options `_ via the :phpfunction: `curl_setopt `
873
874
function. In order to make the component more portable when not using cURL, the
874
- `` CurlHttpClient `` only uses some of those options (and they are ignored in the
875
- rest of clients).
875
+ :class: ` Symfony \\ Component \\ HttpClient \\ CurlHttpClient ` only uses some of those
876
+ options (and they are ignored in the rest of clients).
876
877
877
878
Add an ``extra.curl `` option in your configuration to pass those extra options::
878
879
@@ -1059,7 +1060,8 @@ Canceling Responses
1059
1060
1060
1061
To abort a request (e.g. because it didn't complete in due time, or you want to
1061
1062
fetch only the first bytes of the response, etc.), you can either use the
1062
- ``cancel() `` method of ``ResponseInterface ``::
1063
+ ``cancel() `` method of
1064
+ :class: `Symfony\\ Contracts\\ HttpClient\\ ResponseInterface `::
1063
1065
1064
1066
$response->cancel();
1065
1067
@@ -1073,7 +1075,8 @@ Or throw an exception from a progress callback::
1073
1075
},
1074
1076
]);
1075
1077
1076
- The exception will be wrapped in an instance of ``TransportExceptionInterface ``
1078
+ The exception will be wrapped in an instance of
1079
+ :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ TransportExceptionInterface `
1077
1080
and will abort the request.
1078
1081
1079
1082
In case the response was canceled using ``$response->cancel() ``,
@@ -1273,7 +1276,8 @@ that network errors can happen when calling e.g. ``getStatusCode()`` too::
1273
1276
Because ``$response->getInfo() `` is non-blocking, it shouldn't throw by design.
1274
1277
1275
1278
When multiplexing responses, you can deal with errors for individual streams by
1276
- catching ``TransportExceptionInterface `` in the foreach loop::
1279
+ catching :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ TransportExceptionInterface `
1280
+ in the foreach loop::
1277
1281
1278
1282
foreach ($client->stream($responses) as $response => $chunk) {
1279
1283
try {
@@ -1417,9 +1421,9 @@ PSR-18 and PSR-17
1417
1421
1418
1422
This component implements the `PSR-18 `_ (HTTP Client) specifications via the
1419
1423
:class: `Symfony\\ Component\\ HttpClient\\ Psr18Client ` class, which is an adapter
1420
- to turn a Symfony `` HttpClientInterface `` into a PSR-18 `` ClientInterface ``.
1421
- This class also implements the relevant methods of ` PSR-17 `_ to ease creating
1422
- request objects.
1424
+ to turn a Symfony :class: ` Symfony \\ Contracts \\ HttpClient \\ HttpClientInterface `
1425
+ into a PSR-18 `` ClientInterface ``. This class also implements the relevant
1426
+ methods of ` PSR-17 `_ to ease creating request objects.
1423
1427
1424
1428
To use it, you need the ``psr/http-client `` package and a `PSR-17 `_ implementation:
1425
1429
@@ -1480,9 +1484,9 @@ The `HTTPlug`_ v1 specification was published before PSR-18 and is superseded by
1480
1484
it. As such, you should not use it in newly written code. The component is still
1481
1485
interoperable with libraries that require it thanks to the
1482
1486
:class: `Symfony\\ Component\\ HttpClient\\ HttplugClient ` class. Similarly to
1483
- `` Psr18Client `` implementing relevant parts of PSR-17, `` HttplugClient `` also
1484
- implements the factory methods defined in the related `` php-http/message-factory ``
1485
- package.
1487
+ :class: ` Symfony \\ Component \\ HttpClient \\ Psr18Client ` implementing relevant parts of PSR-17,
1488
+ `` HttplugClient `` also implements the factory methods defined in the related
1489
+ `` php-http/message-factory `` package.
1486
1490
1487
1491
.. code-block :: terminal
1488
1492
@@ -1629,10 +1633,6 @@ The solution is to also decorate the response object itself.
1629
1633
:class: `Symfony\\ Component\\ HttpClient\\ Response\\ TraceableResponse ` are good
1630
1634
examples as a starting point.
1631
1635
1632
- .. versionadded :: 5.2
1633
-
1634
- ``AsyncDecoratorTrait `` was introduced in Symfony 5.2.
1635
-
1636
1636
In order to help writing more advanced response processors, the component provides
1637
1637
an :class: `Symfony\\ Component\\ HttpClient\\ AsyncDecoratorTrait `. This trait allows
1638
1638
processing the stream of chunks as they come back from the network::
@@ -1690,15 +1690,20 @@ has many safety checks that will throw a ``LogicException`` if the chunk
1690
1690
passthru doesn't behave correctly; e.g. if a chunk is yielded after an ``isLast() ``
1691
1691
one, or if a content chunk is yielded before an ``isFirst() `` one, etc.
1692
1692
1693
+ .. versionadded :: 5.2
1694
+
1695
+ :class: `Symfony\\ Component\\ HttpClient\\ AsyncDecoratorTrait ` was introduced in Symfony 5.2.
1696
+
1693
1697
Testing
1694
1698
-------
1695
1699
1696
- This component includes the ``MockHttpClient `` and ``MockResponse `` classes to
1697
- use in tests that shouldn't make actual HTTP requests. Such tests can be
1698
- useful, as they will run faster and produce consistent results, since they're
1699
- not dependent on an external service. By not making actual HTTP requests there
1700
- is no need to worry about the service being online or the request changing
1701
- state, for example deleting a resource.
1700
+ This component includes the :class: `Symfony\\ Component\\ HttpClient\\ MockHttpClient `
1701
+ and :class: `Symfony\\ Component\\ HttpClient\\ Response\\ MockResponse ` classes to use
1702
+ in tests that shouldn't make actual HTTP requests. Such tests can be useful, as they
1703
+ will run faster and produce consistent results, since they're not dependent on an
1704
+ external service. By not making actual HTTP requests there is no need to worry about
1705
+ the service being online or the request changing state, for example deleting
1706
+ a resource.
1702
1707
1703
1708
``MockHttpClient `` implements the ``HttpClientInterface ``, just like any actual
1704
1709
HTTP client in this component. When you type-hint with ``HttpClientInterface ``
0 commit comments