Метод | Описание | |
---|---|---|
configCurlCertificate ( &$ch ) | Will configure CURL handle $ch to use local list of Certificate Authorities, | |
downloadChunk ( string $url, string $outputPath, boolean $isContinuation ) : array | Downloads the next chunk of a specific file. The next chunk's byte range is determined by the existing file's size and the expected file size, which is stored in the piwik_option table before starting a download. The expected file size is obtained through a HEAD HTTP request. | |
ensureDestinationDirectoryExists ( $destinationPath ) | ||
fetchRemoteFile ( string $url, string $destinationPath = null, integer $tries, integer $timeout = 10 ) : boolean | Fetches a file located at $url and saves it to $destinationPath. | |
getModifiedSinceHeader ( ) : string | Returns the If-Modified-Since HTTP header if it can be found. If it cannot be found, an empty string is returned. | |
getTransportMethod ( ) : string | null | Returns the "best" available transport method for {@link sendHttpRequest()} calls. | |
getUserAgent ( ) | ||
sendHttpRequest ( string $aUrl, integer $timeout, string | null $userAgent = null, string | null $destinationPath = null, integer | null $followDepth, boolean $acceptLanguage = false, array | boolean $byteRange = false, boolean $getExtendedInfo = false, string $httpMethod = 'GET', string $httpUsername = null, string $httpPassword = null ) : boolean | string | Sends an HTTP request using best available transport method. | |
sendHttpRequestBy ( string $method = 'socket', string $aUrl, integer $timeout, string $userAgent = null, string $destinationPath = null, resource $file = null, integer $followDepth, boolean | string $acceptLanguage = false, boolean $acceptInvalidSslCertificate = false, array | boolean $byteRange = false, boolean $getExtendedInfo = false, string $httpMethod = 'GET', string $httpUsername = null, string $httpPassword = null, array | string $requestBody = null ) : boolean | Sends an HTTP request using the specified transport method. |
Метод | Описание | |
---|---|---|
isCurlEnabled ( ) | ||
isSocketEnabled ( ) |
Метод | Описание | |
---|---|---|
buildHeadersForPost ( $requestBody ) | ||
getProxyConfiguration ( string $url ) : array | Returns Proxy to use for connecting via HTTP to given URL | |
parseHeaderLine ( array &$headers, string $line ) | Utility function, parses an HTTP header line into key/value & sets header array with them. | |
truncateStr ( string $str, integer $limit ) : string | Utility function that truncates a string to an arbitrary limit. |
public static configCurlCertificate ( &$ch ) |
public static downloadChunk ( string $url, string $outputPath, boolean $isContinuation ) : array | ||
$url | string | The url to download from. |
$outputPath | string | The path to the file to save/append to. |
$isContinuation | boolean | `true` if this is the continuation of a download, or if we're starting a fresh one. |
Результат | array |
public static ensureDestinationDirectoryExists ( $destinationPath ) |
public static fetchRemoteFile ( string $url, string $destinationPath = null, integer $tries, integer $timeout = 10 ) : boolean | ||
$url | string | The URL of the file to download. |
$destinationPath | string | The path to download the file to. |
$tries | integer | (deprecated) |
$timeout | integer | The amount of seconds to wait before aborting the HTTP request. |
Результат | boolean | `true` on success, throws Exception on failure |
public static getModifiedSinceHeader ( ) : string | ||
Результат | string |
public static getTransportMethod ( ) : string | null | ||
Результат | string | null | Either curl, fopen, socket or null if no method is supported. |
public static sendHttpRequest ( string $aUrl, integer $timeout, string | null $userAgent = null, string | null $destinationPath = null, integer | null $followDepth, boolean $acceptLanguage = false, array | boolean $byteRange = false, boolean $getExtendedInfo = false, string $httpMethod = 'GET', string $httpUsername = null, string $httpPassword = null ) : boolean | string | ||
$aUrl | string | The target URL. |
$timeout | integer | The number of seconds to wait before aborting the HTTP request. |
$userAgent | string | null | The user agent to use. |
$destinationPath | string | null | If supplied, the HTTP response will be saved to the file specified by this path. |
$followDepth | integer | null | Internal redirect count. Should always pass `null` for this parameter. |
$acceptLanguage | boolean | The value to use for the `'Accept-Language'` HTTP request header. |
$byteRange | array | boolean | For `Range:` header. Should be two element array of bytes, eg, `array(0, 1024)` Doesn't work w/ `fopen` transport method. |
$getExtendedInfo | boolean | If true returns the status code, headers & response, if false just the response. |
$httpMethod | string | The HTTP method to use. Defaults to `'GET'`. |
$httpUsername | string | HTTP Auth username |
$httpPassword | string | HTTP Auth password |
Результат | boolean | string | If `$destinationPath` is not specified the HTTP response is returned on success. `false` is returned on failure. If `$getExtendedInfo` is `true` and `$destinationPath` is not specified an array with the following information is returned on success: - **status**: the HTTP status code - **headers**: the HTTP headers - **data**: the HTTP response data `false` is still returned on failure. |
public static sendHttpRequestBy ( string $method = 'socket', string $aUrl, integer $timeout, string $userAgent = null, string $destinationPath = null, resource $file = null, integer $followDepth, boolean | string $acceptLanguage = false, boolean $acceptInvalidSslCertificate = false, array | boolean $byteRange = false, boolean $getExtendedInfo = false, string $httpMethod = 'GET', string $httpUsername = null, string $httpPassword = null, array | string $requestBody = null ) : boolean | ||
$method | string | |
$aUrl | string | |
$timeout | integer | in seconds |
$userAgent | string | |
$destinationPath | string | |
$file | resource | |
$followDepth | integer | |
$acceptLanguage | boolean | string | Accept-language header |
$acceptInvalidSslCertificate | boolean | Only used with $method == 'curl'. If set to true (NOT recommended!) the SSL certificate will not be checked |
$byteRange | array | boolean | For Range: header. Should be two element array of bytes, eg, array(0, 1024) Doesn't work w/ fopen method. |
$getExtendedInfo | boolean | True to return status code, headers & response, false if just response. |
$httpMethod | string | The HTTP method to use. Defaults to `'GET'`. |
$httpUsername | string | HTTP Auth username |
$httpPassword | string | HTTP Auth password |
$requestBody | array | string | If $httpMethod is 'POST' this may accept an array of variables or a string that needs to be posted |
Результат | boolean | true (or string/array) on success; false on HTTP response error code (1xx or 4xx) |