Http/Client/Adapter/Socket.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework
LICENSE This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Http  
Subpackage
Client_Adapter  
Version
$Id$  

\Zend_Http_Client_Adapter_Socket

Package: Zend_Http\Client_Adapter
A sockets based (stream_socket_client) adapter class for Zend_Http_Client. Can be used on almost every PHP environment, and does not require any special extensions.
Implements
Children
\Zend_Http_Client_Adapter_Proxy
\Zend_Gdata_App_LoggingHttpClientAdapterSocket
\Zend_Gdata_HttpAdapterStreamingSocket
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Properties

>VPropertyprotectedresource $_context = null
Stream context
Default valuenullDetails
Type
resource
>VPropertyprotectedarray $config = array('persistent' => false, 'ssltransport' => 'ssl', 'sslcert' => null, 'sslpassphrase' => null, 'sslusecontext' => false)
Parameters array
Default valuearray('persistent' => false, 'ssltransport' => 'ssl', 'sslcert' => null, 'sslpassphrase' => null, 'sslusecontext' => false)Details
Type
array
>VPropertyprotectedarray $connected_to = array(null, null)
What host/port are we connected to?
Default valuearray(null, null)Details
Type
array
>VPropertyprotectedstring $method = null
Request method - will be set by write() and might be used by read()
Default valuenullDetails
Type
string
>VPropertyprotectedresource $out_stream = null
Stream for storing output
Default valuenullDetails
Type
resource
>VPropertyprotectedresource|null $socket = null
The socket for server connection
Default valuenullDetails
Type
resource | null

Methods

methodpublic__construct() : void

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

methodpublic__destruct() : void

Destructor: make sure the socket is disconnected

If we are in persistent TCP mode, will not close the connection
methodprotected_checkSocketReadTimeout() : void

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

Throws
ExceptionDescription
\Zend_Http_Client_Adapter_Exceptionwith READ_TIMEOUT code
methodpublicclose() : void

Close the connection to the server

methodpublicconnect(string $host, int $port = 80, boolean $secure = false) : void

Connect to the remote server

Parameters
NameTypeDescription
$hoststring
$portint
$secureboolean
methodpublicgetConfig() : array

Retrieve the array of all configuration options

Returns
TypeDescription
array
methodpublicgetStreamContext() : resource

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

If no stream context is set, will create a default one.
Returns
TypeDescription
resource
methodpublicread() : string

Read response from server

Returns
TypeDescription
string
methodpublicsetConfig( $config = array()) : void

Set the configuration array for the adapter

Parameters
NameTypeDescription
$config
methodpublicsetOutputStream(resource $stream) : \Zend_Http_Client_Adapter_Socket

Set output stream for the response

Parameters
NameTypeDescription
$streamresource
Returns
TypeDescription
\Zend_Http_Client_Adapter_Socket
methodpublicsetStreamContext(mixed $context) : \Zend_Http_Client_Adapter_Socket

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.
Parameters
NameTypeDescription
$contextmixed

Stream context or array of context options

Returns
TypeDescription
\Zend_Http_Client_Adapter_Socket
Details
Since
Zend Framework 1.9  
methodpublicwrite(string $method, \Zend_Uri_Http $uri, string $http_ver = '1.1', array $headers = array(), string $body = '') : string

Send request to the remote server

Parameters
NameTypeDescription
$methodstring
$uri\Zend_Uri_Http
$http_verstring
$headersarray
$bodystring
Returns
TypeDescription
stringRequest as string
Documentation was generated by phpDocumentor 2.2.0 .