XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
HTTP_Request2_SocketWrapper Class Reference
Inheritance diagram for HTTP_Request2_SocketWrapper:
HTTP_Request2_SOCKS5

Public Member Functions

 __construct ($address, $timeout, array $contextOptions=array())
 
 __destruct ()
 
 read ($length)
 
 readLine ($bufferSize, $localTimeout=null)
 
 write ($data)
 
 eof ()
 
 setDeadline ($deadline, $timeout)
 
 enableCrypto ()
 

Protected Member Functions

 checkTimeout ()
 
 connectionWarningsHandler ($errno, $errstr)
 

Protected Attributes

 $connectionWarnings = array()
 
 $socket
 
 $deadline
 
 $timeout
 

Detailed Description

Definition at line 39 of file SocketWrapper.php.

Constructor & Destructor Documentation

HTTP_Request2_SocketWrapper::__construct (   $address,
  $timeout,
array  $contextOptions = array() 
)

Class constructor, tries to establish connection

Parameters
string$addressAddress for stream_socket_client() call, e.g. 'tcp://localhost:80'
int$timeoutConnection timeout (seconds)
array$contextOptionsContext options
Exceptions
HTTP_Request2_LogicException
HTTP_Request2_ConnectionException

Definition at line 76 of file SocketWrapper.php.

HTTP_Request2_SocketWrapper::__destruct ( )

Destructor, disconnects socket

Definition at line 117 of file SocketWrapper.php.

Member Function Documentation

HTTP_Request2_SocketWrapper::checkTimeout ( )
protected

Throws an Exception if stream timed out

Exceptions
HTTP_Request2_MessageException

Definition at line 264 of file SocketWrapper.php.

HTTP_Request2_SocketWrapper::connectionWarningsHandler (   $errno,
  $errstr 
)
protected

Error handler to use during stream_socket_client() call

One stream_socket_client() call may produce multiple PHP warnings (especially OpenSSL-related), we keep them in an array to later use for the message of HTTP_Request2_ConnectionException

Parameters
int$errnoerror level
string$errstrerror message
Returns
bool

Definition at line 289 of file SocketWrapper.php.

HTTP_Request2_SocketWrapper::enableCrypto ( )

Turns on encryption on a socket

Exceptions
HTTP_Request2_ConnectionException

Definition at line 240 of file SocketWrapper.php.

HTTP_Request2_SocketWrapper::eof ( )

Tests for end-of-file on a socket

Returns
bool

Definition at line 216 of file SocketWrapper.php.

HTTP_Request2_SocketWrapper::read (   $length)

Wrapper around fread(), handles global request timeout

Parameters
int$lengthReads up to this number of bytes
Returns
string Data read from socket
Exceptions
HTTP_Request2_MessageExceptionIn case of timeout

Definition at line 130 of file SocketWrapper.php.

HTTP_Request2_SocketWrapper::readLine (   $bufferSize,
  $localTimeout = null 
)

Reads until either the end of the socket or a newline, whichever comes first

Strips the trailing newline from the returned data, handles global request timeout. Method idea borrowed from Net_Socket PEAR package.

Parameters
int$bufferSizebuffer size to use for reading
int$localTimeouttimeout value to use just for this call (used when waiting for "100 Continue" response)
Returns
string Available data up to the newline (not including newline)
Exceptions
HTTP_Request2_MessageExceptionIn case of timeout

Definition at line 153 of file SocketWrapper.php.

HTTP_Request2_SocketWrapper::setDeadline (   $deadline,
  $timeout 
)

Sets request deadline

Parameters
int$deadlineException will be thrown if request continues past this time
int$timeoutOriginal request timeout value, to use in Exception message

Definition at line 229 of file SocketWrapper.php.

HTTP_Request2_SocketWrapper::write (   $data)

Wrapper around fwrite(), handles global request timeout

Parameters
string$dataString to be written
Returns
int
Exceptions
HTTP_Request2_MessageException

Definition at line 197 of file SocketWrapper.php.

Member Data Documentation

HTTP_Request2_SocketWrapper::$connectionWarnings = array()
protected

Definition at line 45 of file SocketWrapper.php.

HTTP_Request2_SocketWrapper::$deadline
protected

Definition at line 57 of file SocketWrapper.php.

HTTP_Request2_SocketWrapper::$socket
protected

Definition at line 51 of file SocketWrapper.php.

HTTP_Request2_SocketWrapper::$timeout
protected

Definition at line 63 of file SocketWrapper.php.


The documentation for this class was generated from the following file: