@@ -19,9 +19,6 @@ Installation
1919
2020 $ composer require symfony/http-client
2121
22- Alternatively, you can clone the `<https://github.com/symfony/http-client >`_
23- repository.
24-
2522 ..include ::/components/require_autoload.rst.inc
2623
2724Basic Usage
@@ -92,12 +89,29 @@ method to perform all kinds of HTTP requests::
9289 $response = $httpClient->request('PUT', 'https://...');
9390 // ...
9491
92+ Responses are always asynchronous, so they are ready as soon as the response
93+ HTTP headers are received, instead of waiting to receive the entire response
94+ contents::
95+
96+ $response = $httpClient->request('GET', 'http://releases.ubuntu.com/18.04.2/ubuntu-18.04.2-desktop-amd64.iso');
97+
98+ // code execution continues immediately; it doesn't wait to receive the response
99+ // you can get the value of any HTTP response header
100+ $contentType = $response->getHeaders()['content-type'][0];
101+
102+ // trying to get the response contents will block the execution until
103+ // the full response contents are received
104+ $contents = $response->getContent();
105+
106+ This component also supports:ref: `streaming responses <http-client-streaming-responses >`
107+ for full asynchronous applications.
108+
95109Authentication
96110~~~~~~~~~~~~~~
97111
98112The HTTP client supports different authentication mechanisms. They can be
99113defined globally when creating the client (to apply it to all requests) and to
100- each request (which overrides any global authentication, if defined )::
114+ each request (which overrides any global authentication)::
101115
102116 // Use the same authentication for all requests
103117 $httpClient = HttpClient::create([
@@ -219,13 +233,6 @@ Concurrent Requests
219233.. TODO
220234
221235
222- Asynchronous Requests
223- ~~~~~~~~~~~~~~~~~~~~~
224-
225-
226- .. TODO see https://gist.github.com/tgalopin/a84a11ece0621b8a79ed923afe015b3c
227-
228-
229236 Processing Responses
230237--------------------
231238
@@ -244,12 +251,14 @@ following methods::
244251 // gets the response body as a string
245252 $content = $response->getContent();
246253
247- // returns info coming from the transport layer, such as "raw_headers ",
254+ // returns info coming from the transport layer, such as "response_headers ",
248255 // "redirect_count", "start_time", "redirect_url", etc.
249256 $httpInfo = $response->getInfo();
250257 // you can get individual info too
251258 $startTime = $response->getInfo('start_time');
252259
260+ .._http-client-streaming-responses ::
261+
253262Streaming Responses
254263~~~~~~~~~~~~~~~~~~~
255264
@@ -415,8 +424,7 @@ the available config options:
415424max_redirects :7
416425max_host_connections :10
417426
418- If you want to define multiple HTTP and API clients, use this other expanded
419- configuration:
427+ If you want to define multiple HTTP clients, use this other expanded configuration:
420428
421429..code-block ::yaml
422430
@@ -432,11 +440,6 @@ configuration:
432440max_host_connections :10
433441max_redirects :7
434442
435- api_clients :
436- github :
437- base_uri :' https://api.github.com'
438- headers :[{ 'Accept': 'application/vnd.github.v3+json' }]
439-
440443 Injecting the HTTP Client Into Services
441444~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
442445
@@ -458,17 +461,16 @@ service by type-hinting a constructor argument with the
458461
459462If you have several clients, you must use any of the methods defined by Symfony
460463to ref:`choose a specific service <services-wire-specific-service> `. Each client
461- has a service associated with it whose name follows the pattern
462- ``client type + client name `` (e.g. ``http_client.crawler ``, ``api_client.github ``).
464+ has a unique service named after its configuration.
463465
464466..code-block ::yaml
465467
466468# config/services.yaml
467469services :
468470# ...
469471
470- # whenever a service type-hintsApiClientInterface , inject the GitHub client
471- Symfony\Contracts\HttpClient\ApiClientInterface :' @api_client.github'
472+ # whenever a service type-hintsHttpClientInterface , inject the GitHub client
473+ Symfony\Contracts\HttpClient\HttpClientInterface :' @api_client.github'
472474
473475# inject the HTTP client called 'crawler' into this argument of this service
474476App\Some\Service :