HTTP Proxy-supporting Zend\Http\Client adapter class, based on the default socket based adapter.

Should be used if proxy HTTP access is required. If no proxy is set, will fall back to Zend\Http\Client\Adapter\Socket behavior. Just like the default Socket adapter, this adapter does not require any special extensions installed.

package Default
inherited_from \Zend\Http\Client\Adapter\Socket

 Methods

Adapter constructor, currently empty. Config is set using setOptions()

__construct() 
Inherited

Destructor: make sure the socket is disconnected

__destruct() 

If we are in persistent TCP mode, will not close the connection

inherited_from \Zend\Http\Client\Adapter\Socket::__destruct()

Destructor: make sure the socket is disconnected

__destruct() 
Inherited

If we are in persistent TCP mode, will not close the connection

Close the connection to the server

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

Close the connection to the server

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

Connect to the remote server

connect(string $host, integer $port = 80, boolean $secure = false

Will try to connect to the proxy server. If no proxy was set, will fall back to the target server (behave like regular Socket adapter)

inherited_from \Zend\Http\Client\Adapter\Socket::connect()

Parameters

$host

string

$port

integer

$secure

boolean

Exceptions

\Zend\Http\Client\Adapter\Exception\RuntimeException

Connect to the remote server

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

Parameters

$host

string

$port

integer

$secure

boolean

Exceptions

\Zend\Http\Client\Adapter\Exception\RuntimeException

Retrieve the array of all configuration options

getConfig() : array
Inherited

Returns

array

Get the stream context for the TCP connection to the server.

getStreamContext() : resource
Inherited

If no stream context is set, will create a default one.

Returns

resource

Read response from server

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

Exceptions

\Zend\Http\Client\Adapter\Exception\RuntimeException

Returns

string

Set the configuration array for the adapter

setOptions(array $options = array()
inherited_from \Zend\Http\Client\Adapter\Socket::setOptions()

Parameters

$options

array

Set the configuration array for the adapter

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

Parameters

$options

array\Traversable

Exceptions

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

Set output stream for the response

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

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\Socket

Set the stream context for the TCP connection to the server

setStreamContext(mixed $context) : \Zend\Http\Client\Adapter\Socket
Inherited

Can accept either a pre-existing stream context resource, or an array of stream options, similar to the options array passed to the stream_context_create() PHP function. In such case a new stream context will be created using the passed options.

since Zend Framework 1.9

Parameters

$context

mixed

Stream context or array of context options

Exceptions

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

Returns

\Zend\Http\Client\Adapter\Socket

Send request to the proxy server

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

Parameters

$method

string

$uri

\Zend\Uri\Uri

$httpVer

string

$headers

array

$body

string

Exceptions

\Zend\Http\Client\Adapter\Exception\RuntimeException

Returns

stringRequest as string

Send request to the remote server

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

Parameters

$method

string

$uri

\Zend\Uri\Uri

$httpVer

string

$headers

array

$body

string

Exceptions

\Zend\Http\Client\Adapter\Exception\RuntimeException

Returns

stringRequest as string

Check if the socket has timed out - if so close connection and throw an exception

_checkSocketReadTimeout() 
Inherited

Exceptions

\Zend\Http\Client\Adapter\Exception\TimeoutException with READ_TIMEOUT code

Preform handshaking with HTTPS proxy using CONNECT method

connectHandshake(string $host, integer $port = 443, string $httpVer = '1.1', array $headers = array()

Parameters

$host

string

$port

integer

$httpVer

string

$headers

array

Exceptions

\Zend\Http\Client\Adapter\Exception\RuntimeException

 Properties

 

Parameters array

$config : array

Default

array('ssltransport' => 'ssl', 'sslcert' => null, 'sslpassphrase' => null, 'sslverifypeer' => true, 'sslcapath' => null, 'sslallowselfsigned' => false, 'sslusecontext' => false, 'proxy_host' => '', 'proxy_port' => 8080, 'proxy_user' => '', 'proxy_pass' => '', 'proxy_auth' => \Zend\Http\Client::AUTH_BASIC, 'persistent' => false)
inherited_from \Zend\Http\Client\Adapter\Socket::config
 

Parameters array

$config : array

Default

array('persistent' => false, 'ssltransport' => 'ssl', 'sslcert' => null, 'sslpassphrase' => null, 'sslverifypeer' => true, 'sslcafile' => null, 'sslcapath' => null, 'sslallowselfsigned' => false, 'sslusecontext' => false)
 

What host/port are we connected to?

$connectedTo : array

Default

array(null, null)
 

Stream context

$context : resource

Default

null
 

Request method - will be set by write() and might be used by read()

$method : string

Default

null
 

Whether HTTPS CONNECT was already negotiated with the proxy or not

$negotiated : boolean

Default

false
 

Stream for storing output

$outStream : resource

Default

null
 

The socket for server connection

$socket : resource | null

Default

null
 

Map SSL transport wrappers to stream crypto method constants

$sslCryptoTypes : array

Default

array('ssl' => STREAM_CRYPTO_METHOD_SSLv23_CLIENT, 'sslv2' => STREAM_CRYPTO_METHOD_SSLv2_CLIENT, 'sslv3' => STREAM_CRYPTO_METHOD_SSLv3_CLIENT, 'tls' => STREAM_CRYPTO_METHOD_TLS_CLIENT)
Static