Zend Framework  1.12
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Zend_Http_Client_Adapter_Socket Class Reference

Public Member Functions

 __construct ()
 Adapter constructor, currently empty.
 
 setConfig ($config=array())
 Set the configuration array for the adapter.
 
 getConfig ()
 Retrieve the array of all configuration options.
 
 setStreamContext ($context)
 Set the stream context for the TCP connection to the server.
 
 getStreamContext ()
 Get the stream context for the TCP connection to the server.
 
 connect ($host, $port=80, $secure=false)
 Connect to the remote server.
 
 write ($method, $uri, $http_ver= '1.1', $headers=array(), $body= '')
 Send request to the remote server.
 
 read ()
 Read response from server.
 
 close ()
 Close the connection to the server.
 
 setOutputStream ($stream)
 Set output stream for the response.
 
 __destruct ()
 Destructor: make sure the socket is disconnected.
 

Protected Member Functions

 _checkSocketReadTimeout ()
 Check if the socket has timed out - if so close connection and throw an exception.
 

Protected Attributes

 $socket = null
 
 $connected_to = array(null, null)
 
 $out_stream = null
 
 $config
 
 $method = null
 
 $_context = null
 

Constructor & Destructor Documentation

__construct ( )

Adapter constructor, currently empty.

Config is set using setConfig()

__destruct ( )

Destructor: make sure the socket is disconnected.

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

Member Function Documentation

_checkSocketReadTimeout ( )
protected

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

Exceptions
Zend_Http_Client_Adapter_Exceptionwith READ_TIMEOUT code
close ( )

Close the connection to the server.

Implements Zend_Http_Client_Adapter_Interface.

connect (   $host,
  $port = 80,
  $secure = false 
)

Connect to the remote server.

Parameters
string$host
int$port
boolean$secure

Implements Zend_Http_Client_Adapter_Interface.

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

Responses to HEAD requests and 204 or 304 responses are not expected to have a body - stop reading here

Implements Zend_Http_Client_Adapter_Interface.

setConfig (   $config = array())

Set the configuration array for the adapter.

Parameters
Zend_Config  |  array$config

Implements Zend_Http_Client_Adapter_Interface.

setOutputStream (   $stream)

Set output stream for the response.

Parameters
resource$stream
Returns
Zend_Http_Client_Adapter_Socket

Implements Zend_Http_Client_Adapter_Stream.

setStreamContext (   $context)

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.

Since
Zend Framework 1.9
Parameters
mixed$contextStream context or array of context options
Returns
Zend_Http_Client_Adapter_Socket
write (   $method,
  $uri,
  $http_ver = '1.1',
  $headers = array(),
  $body = '' 
)

Send request to the remote server.

Parameters
string$method
Zend_Uri_Http$uri
string$http_ver
array$headers
string$body
Returns
string Request as string

Implements Zend_Http_Client_Adapter_Interface.

Member Data Documentation

$_context = null
protected
$config
protected
Initial value:
= array(
'persistent' => false,
'ssltransport' => 'ssl',
'sslcert' => null,
'sslpassphrase' => null,
'sslusecontext' => false
)
$connected_to = array(null, null)
protected
$method = null
protected
$out_stream = null
protected
$socket = null
protected