HTTP_Request2
[ class tree: HTTP_Request2 ] [ index: HTTP_Request2 ] [ all elements ]

Class: HTTP_Request2_SocketWrapper

Source Location: /HTTP_Request2-2.2.1/HTTP/Request2/SocketWrapper.php

Class Overview


Socket wrapper class used by Socket Adapter


Author(s):

Version:

  • Release: 2.2.1

Variables

Methods


Child classes:

HTTP_Request2_SOCKS5
SOCKS5 proxy connection class (used by Socket Adapter)

Inherited Variables

Inherited Methods


Class Details

[line 39]
Socket wrapper class used by Socket Adapter

Needed to properly handle connection errors, global timeout support and similar things. Loosely based on Net_Socket used by older HTTP_Request.



[ Top ]


Class Variables

$connectionWarnings = array()

[line 45]

PHP warning messages raised during stream_socket_client() call
  • Access: protected

Type:   array


[ Top ]

$deadline =

[line 57]

Sum of start time and global timeout, exception will be thrown if request continues past this time
  • Access: protected

Type:   integer


[ Top ]

$socket =

[line 51]

Connected socket
  • Access: protected

Type:   resource


[ Top ]

$timeout =

[line 63]

Global timeout value, mostly for exception messages
  • Access: protected

Type:   integer


[ Top ]



Method Detail

__construct (Constructor)   [line 76]

HTTP_Request2_SocketWrapper __construct( string $address, int $timeout, [ $contextOptions = array()])

Class constructor, tries to establish connection
  • Throws: HTTP_Request2_ConnectionException
  • Throws: HTTP_Request2_LogicException
  • Access: public

Overridden in child classes as:

HTTP_Request2_SOCKS5::__construct()
Constructor, tries to connect and authenticate to a SOCKS5 proxy

Parameters:

string   $address     Address for stream_socket_client() call, e.g. 'tcp://localhost:80'
int   $timeout     Connection timeout (seconds)
array   $contextOptions     Context options

[ Top ]

__destruct (Destructor)   [line 117]

void __destruct( )

Destructor, disconnects socket
  • Access: public

[ Top ]

checkTimeout   [line 264]

void checkTimeout( )

Throws an Exception if stream timed out
  • Throws: HTTP_Request2_MessageException
  • Access: protected

[ Top ]

connectionWarningsHandler   [line 289]

bool connectionWarningsHandler( int $errno, string $errstr)

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

  • Access: protected

Parameters:

int   $errno     error level
string   $errstr     error message

[ Top ]

enableCrypto   [line 240]

void enableCrypto( )

Turns on encryption on a socket
  • Throws: HTTP_Request2_ConnectionException
  • Access: public

[ Top ]

eof   [line 216]

bool eof( )

Tests for end-of-file on a socket
  • Access: public

[ Top ]

read   [line 130]

string read( int $length)

Wrapper around fread(), handles global request timeout
  • Return: Data read from socket
  • Throws: HTTP_Request2_MessageException In case of timeout
  • Access: public

Parameters:

int   $length     Reads up to this number of bytes

[ Top ]

readLine   [line 153]

string readLine( int $bufferSize, [int $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.

  • Return: Available data up to the newline (not including newline)
  • Throws: HTTP_Request2_MessageException In case of timeout
  • Access: public

Parameters:

int   $bufferSize     buffer size to use for reading
int   $localTimeout     timeout value to use just for this call (used when waiting for "100 Continue" response)

[ Top ]

setDeadline   [line 229]

void setDeadline( int $deadline, int $timeout)

Sets request deadline
  • Access: public

Parameters:

int   $deadline     Exception will be thrown if request continues past this time
int   $timeout     Original request timeout value, to use in Exception message

[ Top ]

write   [line 197]

int write( string $data)

Wrapper around fwrite(), handles global request timeout
  • Throws: HTTP_Request2_MessageException
  • Access: public

Parameters:

string   $data     String to be written

[ Top ]


Documentation generated on Thu, 16 Jan 2014 20:00:09 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.