Class Proxy

Summary

Fully Qualified Name: Zend\Http\Client\Adapter\Proxy
Extends: Socket

Description

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.

Methods

Name Description Defined By
__construct() Adapter constructor, currently empty. Config is set using setOptions() Socket
__destruct() Destructor: make sure the socket is disconnected Proxy
close() Close the connection to the server Proxy
connect() Connect to the remote server Proxy
getConfig() Retrieve the array of all configuration options Socket
getStreamContext() Get the stream context for the TCP connection to the server. Socket
read() Read response from server Socket
setOptions() Set the configuration array for the adapter Proxy
setOutputStream() Set output stream for the response Socket
setStreamContext() Set the stream context for the TCP connection to the server Socket
write() Send request to the proxy server Proxy

Method Details

__construct()

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

Returns:

__destruct()

Destructor: make sure the socket is disconnected

Returns:

close()

Close the connection to the server

Returns:

connect()

Connect to the remote server

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)

Parameter Name Type Description
$host string
$port int
$secure bool

Returns:

getConfig()

Retrieve the array of all configuration options

Returns: array

getStreamContext()

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

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

Returns: resource

read()

Read response from server

Returns: string

setOptions()

Set the configuration array for the adapter

Parameter Name Type Description
$options array

Returns:

setOutputStream()

Set output stream for the response

Parameter Name Type Description
$stream resource

Returns: \Zend\Http\Client\Adapter\Socket

setStreamContext()

Set the stream context for the TCP connection to the server

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.

Parameter Name Type Description
$context mixed Stream

Returns: \Socket

write()

Send request to the proxy server

Parameter Name Type Description
$method string
$uri \Zend\Uri\Uri
$httpVer string
$headers array
$body string

Returns: string Request as string

Top