Contao Utils Bundle

CurlRequestUtil
in package

Table of Contents

Constants

HTTP_STATUS_CODE_MESSAGES  = [100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => '(Unused)', 307 => 'Temporary Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported']

Properties

$container  : ContainerInterface
$framework  : ContaoFrameworkInterface
$handle  : HttpRequestInterface

Methods

__construct()  : mixed
createCurlHandle()  : CurlRequest
Create the curl handle.
getHandle()  : HttpRequestInterface|null
postRequest()  : array<string|int, mixed>|mixed
Create a curl post request.
prepareHeaderArrayForPrint()  : string
Creates a linebreak separated list of the headers in $arrHeaders -> see request() and postRequest().
recursiveGetRequest()  : array<string|int, mixed>|mixed|null
Recursivly send get request and terminates if termination condition is given or max request count is reached.
recursivePostRequest()  : array<string|int, mixed>|mixed|null
Recursivly send post request and terminates if termination condition is given or max request count is reached.
request()  : array<string|int, mixed>|mixed
Executes a curl request while taking.
setHandle()  : mixed
splitResponseHeaderAndBody()  : array<string|int, mixed>
prepareHeaders()  : array<string|int, mixed>
Prepare headers for curl handle.

Constants

HTTP_STATUS_CODE_MESSAGES

public mixed HTTP_STATUS_CODE_MESSAGES = [100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => '(Unused)', 307 => 'Temporary Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported']

Properties

Methods

__construct()

public __construct(ContaoFrameworkInterface $framework, ContainerInterface $container) : mixed
Parameters
$framework : ContaoFrameworkInterface
$container : ContainerInterface

postRequest()

Create a curl post request.

public postRequest(string $url[, array<string|int, mixed> $requestHeaders = [] ][, array<string|int, mixed> $postFields = [] ][, bool $returnResponseHeaders = false ]) : array<string|int, mixed>|mixed
Parameters
$url : string
$requestHeaders : array<string|int, mixed> = []
$postFields : array<string|int, mixed> = []
$returnResponseHeaders : bool = false
Return values
array<string|int, mixed>|mixed

prepareHeaderArrayForPrint()

Creates a linebreak separated list of the headers in $arrHeaders -> see request() and postRequest().

public prepareHeaderArrayForPrint(array<string|int, mixed> $headers) : string
Parameters
$headers : array<string|int, mixed>
Return values
string

recursiveGetRequest()

Recursivly send get request and terminates if termination condition is given or max request count is reached.

public recursiveGetRequest(int $maxRecursionCount, callable $callback, string $url[, array<string|int, mixed> $requestHeaders = [] ][, bool $returnResponseHeaders = false ]) : array<string|int, mixed>|mixed|null
Parameters
$maxRecursionCount : int
$callback : callable

Termination condition callback. Return true to terminate.

$url : string
$requestHeaders : array<string|int, mixed> = []
$returnResponseHeaders : bool = false
Return values
array<string|int, mixed>|mixed|null

recursivePostRequest()

Recursivly send post request and terminates if termination condition is given or max request count is reached.

public recursivePostRequest(int $maxRecursionCount, callable $callback, string $url[, array<string|int, mixed> $requestHeaders = [] ][, array<string|int, mixed> $post = [] ][, bool $returnResponseHeaders = false ]) : array<string|int, mixed>|mixed|null
Parameters
$maxRecursionCount : int
$callback : callable
$url : string
$requestHeaders : array<string|int, mixed> = []
$post : array<string|int, mixed> = []
$returnResponseHeaders : bool = false
Return values
array<string|int, mixed>|mixed|null

request()

Executes a curl request while taking.

public request(mixed $url[, array<string|int, mixed> $requestHeaders = [] ][, bool $returnResponseHeaders = false ]) : array<string|int, mixed>|mixed
Parameters
$url : mixed
$requestHeaders : array<string|int, mixed> = []
$returnResponseHeaders : bool = false
Return values
array<string|int, mixed>|mixed

splitResponseHeaderAndBody()

public splitResponseHeaderAndBody(string $response, int $statusCode) : array<string|int, mixed>
Parameters
$response : string
$statusCode : int
Return values
array<string|int, mixed>

prepareHeaders()

Prepare headers for curl handle.

protected prepareHeaders(array<string|int, mixed> $headers) : array<string|int, mixed>
Parameters
$headers : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results