Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a377f07

Browse filesBrowse files
committed
minor #17836 [HttpClient] Replaced code block by :class: when relevant (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [HttpClient] Replaced code block by `:class:` when relevant There are a few locations in HTTP client doc where I think it is relevant to convert doc blocks to `:class:`. Tell me what you think! :+1: Commits ------- 855c0f3 [HttpClient] Replaced code block by `:class:` when relevant
2 parents 02a3d84 + 855c0f3 commit a377f07
Copy full SHA for a377f07

File tree

Expand file treeCollapse file tree

1 file changed

+28
-23
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+28
-23
lines changed

‎http_client.rst

Copy file name to clipboardExpand all lines: http_client.rst
+28-23Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,9 @@ SSRF (Server-side request forgery) Handling
790790
requests to an arbitrary domain. These attacks can also target the internal
791791
hosts and IPs of the attacked server.
792792

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
795796
ensure local networks are made inaccessible to the HTTP client::
796797

797798
use Symfony\Component\HttpClient\HttpClient;
@@ -871,8 +872,8 @@ Configuring CurlHttpClient Options
871872

872873
PHP allows to configure lots of `cURL options`_ via the :phpfunction:`curl_setopt`
873874
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).
876877

877878
Add an ``extra.curl`` option in your configuration to pass those extra options::
878879

@@ -1059,7 +1060,8 @@ Canceling Responses
10591060

10601061
To abort a request (e.g. because it didn't complete in due time, or you want to
10611062
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`::
10631065

10641066
$response->cancel();
10651067

@@ -1073,7 +1075,8 @@ Or throw an exception from a progress callback::
10731075
},
10741076
]);
10751077

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`
10771080
and will abort the request.
10781081

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

12751278
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::
12771281

12781282
foreach ($client->stream($responses) as $response => $chunk) {
12791283
try {
@@ -1417,9 +1421,9 @@ PSR-18 and PSR-17
14171421

14181422
This component implements the `PSR-18`_ (HTTP Client) specifications via the
14191423
: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.
14231427

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

@@ -1480,9 +1484,9 @@ The `HTTPlug`_ v1 specification was published before PSR-18 and is superseded by
14801484
it. As such, you should not use it in newly written code. The component is still
14811485
interoperable with libraries that require it thanks to the
14821486
: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.
14861490

14871491
.. code-block:: terminal
14881492
@@ -1629,10 +1633,6 @@ The solution is to also decorate the response object itself.
16291633
:class:`Symfony\\Component\\HttpClient\\Response\\TraceableResponse` are good
16301634
examples as a starting point.
16311635

1632-
.. versionadded:: 5.2
1633-
1634-
``AsyncDecoratorTrait`` was introduced in Symfony 5.2.
1635-
16361636
In order to help writing more advanced response processors, the component provides
16371637
an :class:`Symfony\\Component\\HttpClient\\AsyncDecoratorTrait`. This trait allows
16381638
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
16901690
passthru doesn't behave correctly; e.g. if a chunk is yielded after an ``isLast()``
16911691
one, or if a content chunk is yielded before an ``isFirst()`` one, etc.
16921692

1693+
.. versionadded:: 5.2
1694+
1695+
:class:`Symfony\\Component\\HttpClient\\AsyncDecoratorTrait` was introduced in Symfony 5.2.
1696+
16931697
Testing
16941698
-------
16951699

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.
17021707

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.