Manual
HTTP client
A PSR-18 client on curl_multi, with PSR-7 requests, responses and URIs.
Introduction#
HttpClient is a PSR-18 client built on curl's multi interface: requests started with phasync::go() in different coroutines run together on one curl handle, and sendRequest() returns a PSR-7 Response once its own request is done. Build the request with Request and a PSR-7 stream such as StringStream for its body. See Concurrent API calls for a worked example.
Guides#
- Concurrent API calls – Call several APIs at once and wait for all of them.
Examples#
- All examples of this topic – 36 with their output.
Reference#
Request– A PSR-7 outgoing, client-side request.Response– A PSR-7 response.ServerRequest– A PSR-7 request as a server received it.Uri– A PSR-7 URI.ClientException– A request failed for a reason that is neither an invalid request nor a network failure.CurlResponse– The PSR-7 response of an HttpClient request, filled in by a cURL transfer.HttpClient– A PSR-18 HTTP client that runs concurrent requests on curl_multi.HttpClientOptions– The options of an HTTP request, as public properties that map to cURL options.NetworkException– No response arrived, or the response stopped arriving, because of a network failure.RequestException– The request could not be sent because it is invalid.