HttpClient
in package
Outbound HTTP client over the WordPress HTTP API (`wp_remote_request()`), with first-class client-certificate (mTLS) support — WP_Http exposes no certificate arguments, so `certPath`/`certPassword`/`keyPath` are applied through an `http_api_curl` action registered before and detached right after the single request. When the active transport never hands the action a cURL handle (non-cURL transport), the request fails loudly instead of silently going out without the client certificate.
Custom args (everything else passes straight to wp_remote_request()):
certPath/certPassword/keyPath— client certificate (mTLS)
Table of Contents
Properties
- $defaultArgs : array<string|int, mixed>
Methods
- __construct() : mixed
- get() : HttpResponse
- post() : HttpResponse
- request() : HttpResponse
- armCertificate() : Closure
- Register the `http_api_curl` action that injects the client certificate into the request's cURL handle, and return the registered closure so the caller can detach it right after the request (no cross-request accumulation). `$armed` flips to true only when the certificate was actually applied to a cURL handle, letting the caller detect transports that silently skip the action (non-cURL) and refuse to degrade.
- extractCertificate() : array{certPath?: string, certPassword?: string, keyPath?: string}
- Pull the mTLS args out of the request args (they are ours, not WP_Http's).
Properties
$defaultArgs
private
array<string|int, mixed>
$defaultArgs
= []
Methods
__construct()
public
__construct([array<string, mixed> $defaultArgs = [] ]) : mixed
Parameters
- $defaultArgs : array<string, mixed> = []
-
merged under every request's args
get()
public
get(string $url[, array<string, mixed> $args = [] ]) : HttpResponse
Parameters
- $url : string
- $args : array<string, mixed> = []
Tags
Return values
HttpResponsepost()
public
post(string $url[, array<string|int, mixed>|string $body = [] ][, array<string, mixed> $args = [] ]) : HttpResponse
Parameters
- $url : string
- $body : array<string|int, mixed>|string = []
- $args : array<string, mixed> = []
Tags
Return values
HttpResponserequest()
public
request(string $method, string $url[, array<string, mixed> $args = [] ]) : HttpResponse
Parameters
- $method : string
- $url : string
- $args : array<string, mixed> = []
Tags
Return values
HttpResponsearmCertificate()
Register the `http_api_curl` action that injects the client certificate into the request's cURL handle, and return the registered closure so the caller can detach it right after the request (no cross-request accumulation). `$armed` flips to true only when the certificate was actually applied to a cURL handle, letting the caller detect transports that silently skip the action (non-cURL) and refuse to degrade.
private
armCertificate(array{certPath?: string, certPassword?: string, keyPath?: string} $certificate, bool &$armed) : Closure
Parameters
- $certificate : array{certPath?: string, certPassword?: string, keyPath?: string}
- $armed : bool
Tags
Return values
ClosureextractCertificate()
Pull the mTLS args out of the request args (they are ours, not WP_Http's).
private
extractCertificate(array<string, mixed> &$args) : array{certPath?: string, certPassword?: string, keyPath?: string}
Parameters
- $args : array<string, mixed>