[ PHPXref.com ] [ Generated: Sun Jul 20 19:38:39 2008 ] [ phpFlickr 2.0.0 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/PEAR/HTTP/ -> Request.php (summary)

(no description)

File Size: 1143 lines (36 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

HTTP_Request:: (29 methods):
  HTTP_Request()
  _generateHostHeader()
  reset()
  setURL()
  setProxy()
  setBasicAuth()
  setMethod()
  setHttpVer()
  addHeader()
  removeHeader()
  addQueryString()
  addRawQueryString()
  addPostData()
  _arrayMapRecursive()
  addFile()
  addRawPostData()
  clearPostData()
  addCookie()
  clearCookies()
  sendRequest()
  getResponseCode()
  getResponseHeader()
  getResponseBody()
  getResponseCookies()
  _buildRequest()
  _flattenArray()
  attach()
  detach()
  _notify()

HTTP_Response:: (6 methods):
  HTTP_Response()
  process()
  _processHeader()
  _parseCookie()
  _readChunked()
  _notify()


Class: HTTP_Request  - X-Ref

HTTP_Request($url = '', $params = array()   X-Ref
Constructor

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

_generateHostHeader()   X-Ref
Generates a Host header for HTTP/1.1 requests

return: string

reset($url, $params = array()   X-Ref
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

setURL($url)   X-Ref
Sets the URL to be requested

param: string The url to be requested

setProxy($host, $port = 8080, $user = null, $pass = null)   X-Ref
Sets a proxy to be used

param: string     Proxy host
param: int        Proxy port
param: string     Proxy username
param: string     Proxy password

setBasicAuth($user, $pass)   X-Ref
Sets basic authentication parameters

param: string     Username
param: string     Password

setMethod($method)   X-Ref
Sets the method to be used, GET, POST etc.

param: string     Method to use. Use the defined constants for this

setHttpVer($http)   X-Ref
Sets the HTTP version to use, 1.0 or 1.1

param: string     Version to use. Use the defined constants for this

addHeader($name, $value)   X-Ref
Adds a request header

param: string     Header name
param: string     Header value

removeHeader($name)   X-Ref
Removes a request header

param: string     Header name to remove

addQueryString($name, $value, $preencoded = false)   X-Ref
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

addRawQueryString($querystring, $preencoded = true)   X-Ref
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

addPostData($name, $value, $preencoded = false)   X-Ref
Adds postdata items

param: string     Post data name
param: string     Post data value
param: bool       Whether data is already urlencoded or not, default = not

_arrayMapRecursive($callback, $value)   X-Ref
Recursively applies the callback function to the value

param: mixed   Callback function
param: mixed   Value to process
return: mixed   Processed value

addFile($inputName, $fileName, $contentType = 'application/octet-stream')   X-Ref
Adds a file to upload

This also changes content-type to 'multipart/form-data' for proper upload

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

addRawPostData($postdata, $preencoded = true)   X-Ref
Adds raw postdata

param: string     The data
param: bool       Whether data is preencoded or not, default = already encoded

clearPostData()   X-Ref
Clears any postdata that has been added (DEPRECATED).

Useful for multiple request scenarios.


addCookie($name, $value)   X-Ref
Appends a cookie to "Cookie:" header

param: string $name cookie name
param: string $value cookie value

clearCookies()   X-Ref
Clears any cookies that have been added (DEPRECATED).

Useful for multiple request scenarios


sendRequest($saveBody = true)   X-Ref
Sends the request

param: bool   Whether to store response body in Response object property,
return: mixed  PEAR error on error, true otherwise

getResponseCode()   X-Ref
Returns the response code

return: mixed     Response code, false if not set

getResponseHeader($headername = null)   X-Ref
Returns either the named header or all if no name given

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)

getResponseBody()   X-Ref
Returns the body of the response

return: mixed     response body, false if not set

getResponseCookies()   X-Ref
Returns cookies set in response

return: mixed     array of response cookies, false if none are present

_buildRequest()   X-Ref
Builds the request string

return: string The request string

_flattenArray($name, $values)   X-Ref
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');

attach(&$listener)   X-Ref
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

detach(&$listener)   X-Ref
Removes a Listener from the list of listeners

param: object   HTTP_Request_Listener instance to detach
return: boolean  whether the listener was successfully detached

_notify($event, $data = null)   X-Ref
Notifies all registered listeners of an event.

Events sent by HTTP_Request object
'sentRequest': after the request was sent
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

Class: HTTP_Response  - X-Ref

Response class to complement the Request class

HTTP_Response(&$sock, &$listeners)   X-Ref
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

process($saveBody = true)   X-Ref
Processes a HTTP response

This extracts response code, headers, cookies and decodes body if it
was encoded in some way

param: bool      Whether to store response body in object property, set
return: mixed     true on success, PEAR_Error in case of malformed response

_processHeader($header)   X-Ref
Processes the response header

param: string    HTTP header

_parseCookie($headervalue)   X-Ref
Parse a Set-Cookie header to fill $_cookies array

param: string    value of Set-Cookie header

_readChunked()   X-Ref
Read a part of response body encoded with chunked Transfer-Encoding

return: string

_notify($event, $data = null)   X-Ref
Notifies all registered listeners of an event.

param: string  Event name
param: mixed   Additional data



[ Powered by PHPXref - Served by Debian GNU/Linux ]