An adapter class for Zend\Http\Client based on the curl extension.

Curl requires libcurl. See for full requirements the PHP manual: http://php.net/curl

package Default

 Methods

Adapter constructor

__construct() 

Config is set using setOptions()

Exceptions

\Zend\Http\Client\Adapter\Exception\InitializationException

Close the connection to the server

close() 
inherited_from \Zend\Http\Client\Adapter\AdapterInterface::close()

Initialize curl

connect(string $host, integer $port = 80, boolean $secure = false) : void
inherited_from \Zend\Http\Client\Adapter\AdapterInterface::connect()

Parameters

$host

string

$port

integer

$secure

boolean

Exceptions

\Zend\Http\Client\Adapter\Exception\RuntimeException if unable to connect

Retrieve the array of all configuration options

getConfig() : array

Returns

array

Get cUrl Handle

getHandle() : resource

Returns

resource

Return read response from server

read() : string
inherited_from \Zend\Http\Client\Adapter\AdapterInterface::read()

Returns

string

Header reader function for CURL

readHeader(resource $curl, string $header) : integer

Parameters

$curl

resource

$header

string

Returns

integer

Direct setter for cURL adapter related options.

setCurlOption(string|integer $option, mixed $value) : \Zend\Http\Client\Adapter\Curl

Parameters

$option

stringinteger

$value

mixed

Returns

\Zend\Http\Client\Adapter\Curl

Set the configuration array for the adapter

setOptions(array|\Traversable $options = array()) : \Zend\Http\Client\Adapter\Curl
inherited_from \Zend\Http\Client\Adapter\AdapterInterface::setOptions()

Parameters

$options

array\Traversable

Exceptions

\Zend\Http\Client\Adapter\Exception\InvalidArgumentException

Returns

\Zend\Http\Client\Adapter\Curl

Set output stream for the response

setOutputStream(resource $stream) : \Zend\Http\Client\Adapter\Curl

This function sets output stream where the result will be stored.

inherited_from \Zend\Http\Client\Adapter\StreamInterface::setOutputStream()

Parameters

$stream

resource

Returns

\Zend\Http\Client\Adapter\Curl

Send request to the remote server

write(string $method, \Zend\Uri\Uri $uri, float $httpVersion = 1.1, array $headers = array(), string $body = '') : string
inherited_from \Zend\Http\Client\Adapter\AdapterInterface::write()

Parameters

$method

string

$uri

\Zend\Uri\Uri

$httpVersion

float

$headers

array

$body

string

Exceptions

\Zend\Http\Client\Adapter\Exception\RuntimeException If connection fails, connected to wrong host, no PUT file defined, unsupported method, or unsupported cURL option.
\Zend\Http\Client\Adapter\Exception\InvalidArgumentException if $method is currently not supported

Returns

string$request

 Properties

 

Parameters array

$config : array

Default

array()
 

What host/port are we connected to?

$connectedTo : array

Default

array(null, null)
 

The curl session handle

$curl : resource | null

Default

null
 

List of cURL options that should never be overwritten

$invalidOverwritableCurlOptions : array

Default

 

Stream for storing output

$outputStream : resource

Default

 

Response gotten from server

$response : string

Default

null