class CurlClient (View source)

Properties

protected $curl
protected $restart
protected $cookies
protected $authentication

Methods

__construct(boolean $restart = false, integer $timeout = 10)

Creates a new HTTP client based on cURL.

__destruct()

Closes the underlying cURL handle.

setTimeout(integer $timeout)

Sets a timeout for the current cURL handler's requests.

string
getRequestCookies()

Returns a string with the list of cookies for the Cookie header.

execute(String $method, String $location)

Executes a Curl.

delete($location, $body = null)

Executes a DELETE on a resource.

get(String $location)

GETs a resource.

post(String $location, String $body)

Executes a POST on a location.

put(String $location, String $body)

PUTs a resource.

setAuthentication(String $credentials)

Sets the authentication string for the next HTTP requests.

setHeader(type $header, type $value)

Sets an HTTP header to send within the request.

restart()

Reinitializes the client for a completely new session.

array
getDefaultCurlOptions()

Returns an array with a set of default options for cURL.

resource
createCurlHandle()

Creates and initializes the underlying cURL handle.

Details

__construct(boolean $restart = false, integer $timeout = 10)

Creates a new HTTP client based on cURL.

Parameters

boolean $restart
integer $timeout

__destruct()

Closes the underlying cURL handle.

setTimeout(integer $timeout)

Sets a timeout for the current cURL handler's requests.

Parameters

integer $timeout

protected string getRequestCookies()

Returns a string with the list of cookies for the Cookie header.

Return Value

string

CurlClientResponse execute(String $method, String $location)

Executes a Curl.

Parameters

String $method
String $location

Return Value

CurlClientResponse

Exceptions

Inconsistent

CurlClientResponse delete($location, $body = null)

Executes a DELETE on a resource.

Parameters

$location
$body

Return Value

CurlClientResponse

CurlClientResponse get(String $location)

GETs a resource.

Parameters

String $location

Return Value

CurlClientResponse

CurlClientResponse post(String $location, String $body)

Executes a POST on a location.

Parameters

String $location
String $body

Return Value

CurlClientResponse

CurlClientResponse put(String $location, String $body)

PUTs a resource.

Parameters

String $location
String $body

Return Value

CurlClientResponse

setAuthentication(String $credentials)

Sets the authentication string for the next HTTP requests.

Parameters

String $credentials

setHeader(type $header, type $value)

Sets an HTTP header to send within the request.

Parameters

type $header
type $value

restart()

Reinitializes the client for a completely new session.

protected array getDefaultCurlOptions()

Returns an array with a set of default options for cURL.

Return Value

array

protected resource createCurlHandle()

Creates and initializes the underlying cURL handle.

Return Value

resource