Package: erfurt

Class HTTP_Request





Description
Variable Summary
mixed $_allowRedirects
mixed $_body
mixed $_bodyDisallowed
mixed $_http
mixed $_listeners
mixed $_maxRedirects
mixed $_method
mixed $_pass
mixed $_postData
mixed $_postFiles
mixed $_proxy_host
mixed $_proxy_pass
mixed $_proxy_port
mixed $_proxy_user
mixed $_readTimeout
mixed $_redirects
mixed $_requestHeaders
mixed $_response
mixed $_saveBody
mixed $_sock
mixed $_socketOptions
mixed $_timeout
mixed $_url
mixed $_useBrackets
mixed $_user
Method Summary
HTTP_Request HTTP_Request ([ $url = ''] , [ $params = array()] )
void addCookie ( $name,  $value)
void addFile ( $inputName,  $fileName, [ $contentType = 'application/octet-stream'] )
void addHeader ( $name,  $value)
void addPostData ( $name,  $value, [ $preencoded = false] )
void addQueryString ( $name,  $value, [ $preencoded = false] )
void addRawPostData ( $postdata, [ $preencoded = true] )
void addRawQueryString ( $querystring, [ $preencoded = true] )
void attach ( &$listener)
void clearCookies ()
void clearPostData ()
void detach ( &$listener)
void disconnect ()
void getResponseBody ()
void getResponseCode ()
void getResponseCookies ()
void getResponseHeader ([ $headername = null] )
void getUrl ( $url)
void removeHeader ( $name)
void reset ( $url, [ $params = array()] )
void sendRequest ([ $saveBody = true] )
void setBasicAuth ( $user,  $pass)
void setBody ( $body)
void setHttpVer ( $http)
void setMethod ( $method)
void setProxy ( $host, [ $port = 8080] , [ $user = null] , [ $pass = null] )
void setURL ( $url)
void _arrayMapRecursive ( $callback,  $value)
void _buildRequest ()
void _flattenArray ( $name,  $values)
void _generateHostHeader ()
void _notify ( $event, [ $data = null] )
Variables
$_allowRedirects
mixed $_allowRedirects

* Whether to allow redirects * @var boolean

$_body
mixed $_body

* Request body * @var string

$_bodyDisallowed = array('TRACE')
mixed $_bodyDisallowed = array('TRACE')

* A list of methods that MUST NOT have a request body, per RFC 2616 * @var array

$_http
mixed $_http

* HTTP Version * @var string

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

* Attached listeners * @var array

$_maxRedirects
mixed $_maxRedirects

* Maximum redirects allowed * @var integer

$_method
mixed $_method

* Type of request * @var string

$_pass
mixed $_pass

* Basic Auth Password * @var string

$_postData
mixed $_postData

* Post data * @var array

$_postFiles = array()
mixed $_postFiles = array()

* Files to post * @var array

$_proxy_host
mixed $_proxy_host

* Proxy server * @var string

$_proxy_pass
mixed $_proxy_pass

* Proxy password * @var string

$_proxy_port
mixed $_proxy_port

* Proxy port * @var integer

$_proxy_user
mixed $_proxy_user

* Proxy username * @var string

$_readTimeout = null
mixed $_readTimeout = null

* Timeout for reading from socket (array(seconds, microseconds)) * @var array

$_redirects
mixed $_redirects

* Current number of redirects * @var integer

$_requestHeaders
mixed $_requestHeaders

* Request headers * @var array

$_response
mixed $_response

* HTTP_Response object * @var object HTTP_Response

$_saveBody = true
mixed $_saveBody = true

* Whether to save response body in response object property * @var bool

$_sock
mixed $_sock

* Socket object * @var object Net_Socket

$_socketOptions = null
mixed $_socketOptions = null

* Options to pass to Net_Socket::connect. See stream_context_create * @var array

$_timeout
mixed $_timeout

* Connection timeout. * @var float

$_url
mixed $_url

* Instance of Net_URL * @var object Net_URL

$_useBrackets = true
mixed $_useBrackets = true

* Whether to append brackets [] to array variables * @var bool

$_user
mixed $_user

* Basic Auth Username * @var string

Methods
Constructor HTTP_Request
HTTP_Request HTTP_Request ( [ $url = '' ] , [ $params = array() ] )

* Constructor * * Sets up the object * @param string The url to fetch/access * @param array Associative array of parameters which can have the following keys: *

  • method - Method to use, GET, POST etc (string)
  • http - HTTP Version to use, 1.0 or 1.1 (string)
  • user - Basic Auth username (string)
  • pass - Basic Auth password (string)
  • proxy_host - Proxy server host (string)
  • proxy_port - Proxy server port (integer)
  • proxy_user - Proxy auth username (string)
  • proxy_pass - Proxy auth password (string)
  • timeout - Connection timeout in seconds (float)
  • allowRedirects - Whether to follow redirects or not (bool)
  • maxRedirects - Max number of redirects to follow (integer)
  • useBrackets - Whether to append [] to array variable names (bool)
  • saveBody - Whether to save response body in response object property (bool)
  • readTimeout - Timeout for reading / writing data over the socket (array (seconds, microseconds))
  • socketOptions - Options to pass to Net_Socket object (array)
* @access public

Parameters:
  • $url
  • $params
addCookie
void addCookie ( $name , $value )

* Appends a cookie to "Cookie:" header * * @param string $name cookie name * @param string $value cookie value * @access public

Parameters:
  • $name
  • $value
addFile
void addFile ( $inputName , $fileName , [ $contentType = 'application/octet-stream' ] )

* Adds a file to upload * * This also changes content-type to 'multipart/form-data' for proper upload * * @access public * @param string name of file-upload field * @param mixed file name(s) * @param mixed content-type(s) of file(s) being uploaded * @return bool true on success * @throws PEAR_Error

Parameters:
  • $inputName
  • $fileName
  • $contentType
addHeader
void addHeader ( $name , $value )

* Adds a request header * * @param string Header name * @param string Header value * @access public

Parameters:
  • $name
  • $value
addPostData
void addPostData ( $name , $value , [ $preencoded = false ] )

* Adds postdata items * * @param string Post data name * @param string Post data value * @param bool Whether data is already urlencoded or not, default = not * @access public

Parameters:
  • $name
  • $value
  • $preencoded
addQueryString
void addQueryString ( $name , $value , [ $preencoded = false ] )

* Adds a querystring parameter * * @param string Querystring parameter name * @param string Querystring parameter value * @param bool Whether the value is already urlencoded or not, default = not * @access public

Parameters:
  • $name
  • $value
  • $preencoded
addRawPostData
void addRawPostData ( $postdata , [ $preencoded = true ] )

* Adds raw postdata (DEPRECATED) * * @param string The data * @param bool Whether data is preencoded or not, default = already encoded * @access public * @deprecated deprecated since 1.3.0, method setBody() should be used instead

Parameters:
  • $postdata
  • $preencoded
addRawQueryString
void addRawQueryString ( $querystring , [ $preencoded = true ] )

* Sets the querystring to literally what you supply * * @param string The querystring data. Should be of the format foo=bar&x=y etc * @param bool Whether data is already urlencoded or not, default = already encoded * @access public

Parameters:
  • $querystring
  • $preencoded
attach
void attach ( &$listener )

* Adds a Listener to the list of listeners that are notified of * the object's events * * @param object HTTP_Request_Listener instance to attach * @return boolean whether the listener was successfully attached * @access public

Parameters:
  • &$listener
clearCookies
void clearCookies ()

* Clears any cookies that have been added (DEPRECATED). * * Useful for multiple request scenarios * * @access public * @deprecated deprecated since 1.2

clearPostData
void clearPostData ()

* Clears any postdata that has been added (DEPRECATED). * * Useful for multiple request scenarios. * * @access public * @deprecated deprecated since 1.2

detach
void detach ( &$listener )

* Removes a Listener from the list of listeners * * @param object HTTP_Request_Listener instance to detach * @return boolean whether the listener was successfully detached * @access public

Parameters:
  • &$listener
disconnect
void disconnect ()

* Disconnect the socket, if connected. Only useful if using Keep-Alive. * * @access public

getResponseBody
void getResponseBody ()

* Returns the body of the response * * @access public * @return mixed response body, false if not set

getResponseCode
void getResponseCode ()

* Returns the response code * * @access public * @return mixed Response code, false if not set

getResponseCookies
void getResponseCookies ()

* Returns cookies set in response * * @access public * @return mixed array of response cookies, false if none are present

getResponseHeader
void getResponseHeader ( [ $headername = null ] )

* Returns either the named header or all if no name given * * @access public * @param string The header name to return, do not set to get all headers * @return mixed either the value of $headername (false if header is not present) * or an array of all headers

Parameters:
  • $headername
getUrl
void getUrl ( $url )

* Returns the current request URL * * @return string Current request URL * @access public

Parameters:
  • $url
removeHeader
void removeHeader ( $name )

* Removes a request header * * @param string Header name to remove * @access public

Parameters:
  • $name
reset
void reset ( $url , [ $params = array() ] )

* Resets the object to its initial state (DEPRECATED). * Takes the same parameters as the constructor. * * @param string $url The url to be requested * @param array $params Associative array of parameters * (see constructor for details) * @access public * @deprecated deprecated since 1.2, call the constructor if this is necessary

Parameters:
  • $url
  • $params
sendRequest
void sendRequest ( [ $saveBody = true ] )

* Sends the request * * @access public * @param bool Whether to store response body in Response object property, * set this to false if downloading a LARGE file and using a Listener * @return mixed PEAR error on error, true otherwise

Parameters:
  • $saveBody
setBasicAuth
void setBasicAuth ( $user , $pass )

* Sets basic authentication parameters * * @param string Username * @param string Password

Parameters:
  • $user
  • $pass
setBody
void setBody ( $body )

* Sets the request body (for POST, PUT and similar requests) * * @param string Request body * @access public

Parameters:
  • $body
setHttpVer
void setHttpVer ( $http )

* Sets the HTTP version to use, 1.0 or 1.1 * * @param string Version to use. Use the defined constants for this * @access public

Parameters:
  • $http
setMethod
void setMethod ( $method )

* Sets the method to be used, GET, POST etc. * * @param string Method to use. Use the defined constants for this * @access public

Parameters:
  • $method
setProxy
void setProxy ( $host , [ $port = 8080 ] , [ $user = null ] , [ $pass = null ] )

* Sets a proxy to be used * * @param string Proxy host * @param int Proxy port * @param string Proxy username * @param string Proxy password * @access public

Parameters:
  • $host
  • $port
  • $user
  • $pass
setURL
void setURL ( $url )

* Sets the URL to be requested * * @param string The url to be requested * @access public

Parameters:
  • $url
_arrayMapRecursive
void _arrayMapRecursive ( $callback , $value )

* Recursively applies the callback function to the value * * @param mixed Callback function * @param mixed Value to process * @access private * @return mixed Processed value

Parameters:
  • $callback
  • $value
_buildRequest
void _buildRequest ()

* Builds the request string * * @access private * @return string The request string

_flattenArray
void _flattenArray ( $name , $values )

* Helper function to change the (probably multidimensional) associative array * into the simple one. * * @param string name for item * @param mixed item's values * @return array array with the following items: array('item name', 'item value');

Parameters:
  • $name
  • $values
_generateHostHeader
void _generateHostHeader ()

* Generates a Host header for HTTP/1.1 requests * * @access private * @return string

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

* Notifies all registered listeners of an event. * * Events sent by HTTP_Request object * - 'connect': on connection to server * - 'sentRequest': after the request was sent * - 'disconnect': on disconnection from server * * Events sent by HTTP_Response object * - 'gotHeaders': after receiving response headers (headers are passed in $data) * - 'tick': on receiving a part of response body (the part is passed in $data) * - 'gzTick': on receiving a gzip-encoded part of response body (ditto) * - 'gotBody': after receiving the response body (passes the decoded body in $data if it was gzipped) * * @param string Event name * @param mixed Additional data * @access private

Parameters:
  • $event
  • $data

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