CRM_Utils_HttpClient
in package
This class handles HTTP downloads
FIXME: fetch() and get() report errors differently -- e.g. fetch() returns fatal and get() returns an error code. Should refactor both (or get a third-party HTTP library) but don't want to deal with that so late in the 4.3 dev cycle.
Tags
Table of Contents
Constants
- STATUS_DL_ERROR = 'dl-error'
- STATUS_OK = 'ok'
- STATUS_WRITE_ERROR = 'write-error'
Properties
- $connectionTimeout : int|null
- $singleton : CRM_Utils_HttpClient
Methods
- __construct() : mixed
- fetch() : STATUS_OK|STATUS_WRITE_ERROR|STATUS_DL_ERROR
- Download the remote zipfile.
- get() : array<string|int, mixed>
- Send an HTTP GET for a remote resource.
- isRedirectSupported() : bool
- post() : array<string|int, mixed>
- Send an HTTP POST for a remote resource.
- singleton() : CRM_Utils_HttpClient
- createCurl() : array<string|int, mixed>
Constants
STATUS_DL_ERROR
public
mixed
STATUS_DL_ERROR
= 'dl-error'
STATUS_OK
public
mixed
STATUS_OK
= 'ok'
STATUS_WRITE_ERROR
public
mixed
STATUS_WRITE_ERROR
= 'write-error'
Properties
$connectionTimeout
protected
int|null
$connectionTimeout
seconds; or NULL to use system default
$singleton
protected
static CRM_Utils_HttpClient
$singleton
Methods
__construct()
public
__construct([int|null $connectionTimeout = NULL ]) : mixed
Parameters
- $connectionTimeout : int|null = NULL
-
seconds; or NULL to use system default
fetch()
Download the remote zipfile.
public
fetch(string $remoteFile, string $localFile) : STATUS_OK|STATUS_WRITE_ERROR|STATUS_DL_ERROR
Parameters
- $remoteFile : string
-
URL of a .zip file.
- $localFile : string
-
Path at which to store the .zip file.
Tags
Return values
STATUS_OK|STATUS_WRITE_ERROR|STATUS_DL_ERRORget()
Send an HTTP GET for a remote resource.
public
get(string $remoteFile) : array<string|int, mixed>
Parameters
- $remoteFile : string
-
URL of remote file.
Return values
array<string|int, mixed> —array(0 => STATUS_OK|STATUS_DL_ERROR, 1 => string)
isRedirectSupported()
public
isRedirectSupported() : bool
Return values
boolpost()
Send an HTTP POST for a remote resource.
public
post(string $remoteFile, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $remoteFile : string
-
URL of a .zip file.
- $params : array<string|int, mixed>
Return values
array<string|int, mixed> —array(0 => STATUS_OK|STATUS_DL_ERROR, 1 => string)
singleton()
public
static singleton() : CRM_Utils_HttpClient
Return values
CRM_Utils_HttpClientcreateCurl()
protected
createCurl(string $remoteFile) : array<string|int, mixed>
Parameters
- $remoteFile : string
Return values
array<string|int, mixed> —(0 => resource, 1 => CA_Config_Curl)