HttpTransport
final class HttpTransport implements TransportInterface (View source)
Low-level HTTP transport over cURL.
Owns the cURL handle lifecycle and exposes a single post() method.
Constants
| PROTECTED_OPTIONS |
cURL options this transport owns; a caller may not override them through
the per-call option bag ({AbstractClient::setExtraCurlOptions()}). Passing one of these to {\CNIC\post()} raises {\CNIC\Exception\UnsupportedFeatureException} rather than being silently dropped. Two kinds of option, protected for two different reasons:
Everything else the transport sets (CURLOPT_TIMEOUT, CONNECTTIMEOUT, USERAGENT) is a default the caller may override. CURLOPT_HTTPHEADER is the one middle case: callers may add header lines but not restate the transport's own — see {\CNIC\appendHeaders()}. Keyed by the cURL constant, valued with its name, so the rejection message can name what the caller passed instead of handing back a bare integer to look up. One list, not two: a second list of the same constants could drift out of step with this one. Keep the list exactly the envelope and TLS keys — widening it silently re-breaks legitimate tuning, narrowing it gives away one of the two guarantees. Pinned by HttpTransportCurlOptionsTest::testProtectedOptionsAreExactlyTheEnvelopeAndTlsKeys(). |
Methods
Execute a POST request and return the raw response.
Close and reset the cURL handle.
Details
array
post(string $url, string $data, int $timeoutSeconds, string $userAgent, array $options = [])
Execute a POST request and return the raw response.
The caller's $options win over the transport's own defaults on key collision, except for {\CNIC\PROTECTED_OPTIONS}, which are rejected. CURLOPT_HTTPHEADER is additive: caller lines are appended to the transport's, and restating one of the transport's own headers is rejected rather than allowed to override it (see {\CNIC\appendHeaders()}).
void
close()
Close and reset the cURL handle.