Package: erfurt

Class HTTP_Response





Description

* Response class to complement the Request class

Variable Summary
mixed $_body
mixed $_chunkLength
mixed $_code
mixed $_cookies
mixed $_headers
mixed $_listeners
mixed $_protocol
mixed $_sock
mixed $_toRead
Method Summary
HTTP_Response HTTP_Response ( &$sock,  &$listeners)
void process ([ $saveBody = true] , [ $canHaveBody = true] )
void _decodeGzip ( $data)
void _notify ( $event, [ $data = null] )
void _parseCookie ( $headervalue)
void _processHeader ( $header)
void _readChunked ()
Variables
$_body = ''
mixed $_body = ''

* Response body * @var string

$_chunkLength = 0
mixed $_chunkLength = 0

* Used by _readChunked(): remaining length of the current chunk * @var string

$_code
mixed $_code

* Return code * @var string

$_cookies
mixed $_cookies

* Cookies set in response * @var array

$_headers
mixed $_headers

* Response headers * @var array

$_listeners = array()
mixed $_listeners = array()

* Attached listeners * @var array

$_protocol
mixed $_protocol

* Protocol * @var string

$_sock
mixed $_sock

* Socket object * @var object

$_toRead
mixed $_toRead

* Bytes left to read from message-body * @var null|int

Methods
Constructor HTTP_Response
HTTP_Response HTTP_Response ( &$sock , &$listeners )

* Constructor * * @param object Net_Socket socket to read the response from * @param array listeners attached to request * @return mixed PEAR Error on error, true otherwise

Parameters:
  • &$sock
  • &$listeners
process
void process ( [ $saveBody = true ] , [ $canHaveBody = true ] )

* Processes a HTTP response * * This extracts response code, headers, cookies and decodes body if it * was encoded in some way * * @access public * @param bool Whether to store response body in object property, set * this to false if downloading a LARGE file and using a Listener. * This is assumed to be true if body is gzip-encoded. * @param bool Whether the response can actually have a message-body. * Will be set to false for HEAD requests. * @throws PEAR_Error * @return mixed true on success, PEAR_Error in case of malformed response

Parameters:
  • $saveBody
  • $canHaveBody
_decodeGzip
void _decodeGzip ( $data )

* Decodes the message-body encoded by gzip * * The real decoding work is done by gzinflate() built-in function, this * method only parses the header and checks data for compliance with * RFC 1952 * * @access private * @param string gzip-encoded data * @return string decoded data

Parameters:
  • $data
_notify
void _notify ( $event , [ $data = null ] )

* Notifies all registered listeners of an event. * * @param string Event name * @param mixed Additional data * @access private * @see HTTP_Request::_notify()

Parameters:
  • $event
  • $data
_parseCookie
void _parseCookie ( $headervalue )

* Parse a Set-Cookie header to fill $_cookies array * * @access private * @param string value of Set-Cookie header

Parameters:
  • $headervalue
_processHeader
void _processHeader ( $header )

* Processes the response header * * @access private * @param string HTTP header

Parameters:
  • $header
_readChunked
void _readChunked ()

* Read a part of response body encoded with chunked Transfer-Encoding * * @access private * @return string

Documentation generated on 2009-01-06 at 01:01 by phpDocumentor 1.4.1