The package wraps Quantum-owned native cURL adapters behind the same HttpClient API.
You begin in one of three ways:
createRequest($url)for one requestcreateMultiRequest()for a collected batchcreateAsyncMultiRequest($success, $error)for callback-driven batches
Each method replaces the current internal adapter instance.
It does not reset the wrapper's other state. The current HTTP method, pending data payload, tracked request headers, collected responses, and collected errors all stay on the same HttpClient object until you overwrite them or create a fresh wrapper instance.
HttpClient exposes a small native API (setMethod(), setData(), start()) and forwards supported adapter methods through __call().
Supported passthrough methods include:
setHeader()setHeaders()setOpt()addGet()addPost()
If the wrapped client does not have the requested method, __call() throws HttpClientException::methodNotSupported(...).
For a single request, start() calls an internal startSingleRequest() method that:
- applies
CURLOPT_CUSTOMREQUESTfromsetMethod() - applies
CURLOPT_POSTFIELDSwhensetData()holds a truthy value - executes the request
- stores headers, cookies, body, and any transport error
For a normal multi request, start() calls the native MultiCurlAdapter. Each completed request is passed into handleResponse() by the callback registered in createMultiRequest().
For async multi requests, Quantum installs the same completion collector used by normal multi requests and also wires your success and error callbacks. Your callbacks are useful for per-request side effects, while getResponse() and getErrors() remain available after start() finishes.
Quantum stores completed data in two internal arrays:
$response[$curlId]$errors[$curlId]
Each response entry contains:
headerscookiesbody
Each error entry contains:
codemessage
On single requests, public getters collapse the storage down to the current request ID.
On multi requests, public getters return the full ID-keyed maps.
The package keeps a separate $requestHeaders array for headers you set through proxied:
setHeader($name, $value)setHeaders([...])
Those keys are lowercased before storage.
This is only a bookkeeping layer for later reads through getRequestHeaders(). It does not inspect headers set through unrelated low-level cURL options.
Several read methods call ensureSingleRequest() first.
If the current adapter is a multi-request adapter, these methods fail instead of guessing which request you meant:
getRequestHeaders()getResponseHeaders()getResponseCookies()getResponseBody()info()url()
That contract keeps the single-request API predictable, but it means multi-request consumers must work with the aggregated response arrays instead.