cURL HTTP transport

package Requests
subpackage Transport

 Methods

Constructor

__construct() 

Destructor

__destruct() 

Get the cURL handle for use in a multi-request

get_subrequest_handle(string $url, array $headers, string|array $data, array $options) : resource

Parameters

$url

string

URL to request

$headers

array

Associative array of request headers

$data

stringarray

Data to send either as the POST body, or as parameters in the URL for a GET/HEAD

$options

array

Request options, see {@see Requests::response()} for documentation

Returns

resourceSubrequest's cURL handle

Process a response

process_response(string $response, array $options) : string

Parameters

$response

string

Response data from the body

$options

array

Request options

Returns

stringHTTP response data including headers

Perform a request

request(string $url, array $headers = array(), string|array $data = array(), array $options = array()) : string
inherited_from \Requests_Transport::request()

Parameters

$url

string

URL to request

$headers

array

Associative array of request headers

$data

stringarray

Data to send either as the POST body, or as parameters in the URL for a GET/HEAD

$options

array

Request options, see {@see Requests::response()} for documentation

Exceptions

\Requests_Exception On a cURL error (`curlerror`)

Returns

stringRaw HTTP result

Send multiple requests simultaneously

request_multiple(array $requests, array $options) : array
inherited_from \Requests_Transport::request_multiple()

Parameters

$requests

array

Request data

$options

array

Global options

Returns

arrayArray of Requests_Response objects (may contain Requests_Exception or string responses as well)

Collect data as it's received

stream_body(resource $handle, string $data) : integer
since 1.6.1

Parameters

$handle

resource

cURL resource

$data

string

Body data

Returns

integerLength of provided data

Collect the headers as they are received

stream_headers(resource $handle, string $headers) : integer

Parameters

$handle

resource

cURL resource

$headers

string

Header string

Returns

integerLength of provided header

Whether this transport is valid

test($capabilities = array()) : boolean
Static
codeCoverageIgnore
inherited_from \Requests_Transport::test()

Parameters

$capabilities

Returns

booleanTrue if the transport is valid, false otherwise.

Format a URL given GET data

format_get(string $url, array|object $data) : string
Static

Parameters

$url

string

$data

arrayobject

Data to build query using, see {@see https://secure.php.net/http_build_query}

Returns

stringURL with data

Setup the cURL handle for the given data

setup_handle(string $url, array $headers, string|array $data, array $options) 

Parameters

$url

string

URL to request

$headers

array

Associative array of request headers

$data

stringarray

Data to send either as the POST body, or as parameters in the URL for a GET/HEAD

$options

array

Request options, see {@see Requests::response()} for documentation

 Properties

 

Raw HTTP data

$headers : string

Default

''
 

Information on the current request

$info : array

Default

 

Raw body data

$response_data : string

Default

''
 

Version string

$version : \long

Default

 

Have we finished the headers yet?

$done_headers : boolean

Default

false
 

cURL handle

$handle : resource

Default

 

Hook dispatcher instance

$hooks : \Requests_Hooks

Default

 

What's the maximum number of bytes we should keep?

$response_byte_limit : integer | boolean

Default

 

How many bytes are in the response body?

$response_bytes : integer

Default

 

If streaming to a file, keep the file pointer

$stream_handle : resource

Default

 Constants

 

CURL_7_10_5

CURL_7_10_5 = 461317 
 

CURL_7_16_2

CURL_7_16_2 = 462850