Class SimpleUserAgent

Description

Fetches web pages whilst keeping track of cookies and authentication.

Located in /user_agent.php (line 31)


	
			
Variable Summary
Method Summary
 SimpleUserAgent SimpleUserAgent ()
 void addHeader (string $header)
 void ageCookies (integer $interval)
 SimpleHttpResponse &fetchResponse (string/SimpleUrl $url, SimpleEncoding $encoding)
 string/boolean getBaseCookieValue (string $name, SimpleUrl $base)
 string getCookieValue (string $host, string $path, string $name)
 void ignoreCookies ()
 void restart ([string/integer $date = false])
 void setConnectionTimeout (integer $timeout)
 void setCookie (string $name, string $value, [string $host = false], [string $path = '/'], [string $expiry = false])
 void setIdentity (string $host, string $realm, string $username, string $password)
 void setMaximumRedirects (integer $max)
 void useCookies ()
 void useProxy (string $proxy, string $username, string $password)
 SimpleHttpRequest &_createHttpRequest (SimpleUrl $url,  $encoding, SimpleFormEncoding $parameters)
 SimpleHttpResponse &_fetch (SimpleUrl $url, SimpleFormEncoding $encoding)
Variables
mixed $_additional_headers = array() (line 40)
mixed $_authenticator (line 34)
mixed $_connection_timeout = DEFAULT_CONNECTION_TIMEOUT (line 39)
mixed $_cookies_enabled = true (line 33)
mixed $_cookie_jar (line 32)
mixed $_max_redirects = DEFAULT_MAX_REDIRECTS (line 35)
mixed $_proxy = false (line 36)
mixed $_proxy_password = false (line 38)
mixed $_proxy_username = false (line 37)
Methods
Constructor SimpleUserAgent (line 46)

Starts with no cookies, realms or proxies.

  • access: public
SimpleUserAgent SimpleUserAgent ()
addHeader (line 71)

Adds a header to every fetch.

  • access: public
void addHeader (string $header)
  • string $header: Header line to add to every request until cleared.
ageCookies (line 80)

Ages the cookies by the specified time.

  • access: public
void ageCookies (integer $interval)
  • integer $interval: Amount in seconds.
fetchResponse (line 214)

Fetches a URL as a response object. Will keep trying if redirected.

It will also collect authentication realm information.

  • return: Hopefully the target page.
  • access: public
SimpleHttpResponse &fetchResponse (string/SimpleUrl $url, SimpleEncoding $encoding)
  • string/SimpleUrl $url: Target to fetch.
  • SimpleEncoding $encoding: Additional parameters for request.
getBaseCookieValue (line 120)

Reads the current cookies within the base URL.

  • return: Null if there is no base URL, false if the cookie is not set.
  • access: public
string/boolean getBaseCookieValue (string $name, SimpleUrl $base)
  • string $name: Key of cookie to find.
  • SimpleUrl $base: Base URL to search from.
getCookieValue (line 108)

Reads the most specific cookie value from the browser cookies.

  • return: False if not present, else the value as a string.
  • access: public
string getCookieValue (string $host, string $path, string $name)
  • string $host: Host to search.
  • string $path: Applicable path.
  • string $name: Name of cookie to read.
ignoreCookies (line 131)

Switches off cookie sending and recieving.

  • access: public
void ignoreCookies ()
restart (line 60)

Removes expired and temporary cookies as if the browser was closed and re-opened. Authorisation has to be obtained again as well.

  • access: public
void restart ([string/integer $date = false])
  • string/integer $date: Time when session restarted. If omitted then all persistent cookies are kept.
setConnectionTimeout (line 148)

Sets the socket timeout for opening a connection.

  • access: public
void setConnectionTimeout (integer $timeout)
  • integer $timeout: Maximum time in seconds.
setCookie (line 94)

Sets an additional cookie. If a cookie has the same name and path it is replaced.

  • access: public
void setCookie (string $name, string $value, [string $host = false], [string $path = '/'], [string $expiry = false])
  • string $name: Cookie key.
  • string $value: Value of cookie.
  • string $host: Host upon which the cookie is valid.
  • string $path: Cookie path if not host wide.
  • string $expiry: Expiry date.
setIdentity (line 202)

Sets the identity for the current realm.

  • access: public
void setIdentity (string $host, string $realm, string $username, string $password)
  • string $host: Host to which realm applies.
  • string $realm: Full name of realm.
  • string $username: Username for realm.
  • string $password: Password for realm.
setMaximumRedirects (line 158)

Sets the maximum number of redirects before a page will be loaded anyway.

  • access: public
void setMaximumRedirects (integer $max)
  • integer $max: Most hops allowed.
useCookies (line 139)

Switches back on the cookie sending and recieving.

  • access: public
void useCookies ()
useProxy (line 171)

Sets proxy to use on all requests for when testing from behind a firewall. Set URL to false to disable.

  • access: public
void useProxy (string $proxy, string $username, string $password)
  • string $proxy: Proxy URL.
  • string $username: Proxy username for authentication.
  • string $password: Proxy password for authentication.
_createHttpRequest (line 297)

Builds the appropriate HTTP request object.

  • return: New request object.
  • access: protected
SimpleHttpRequest &_createHttpRequest (SimpleUrl $url,  $encoding, SimpleFormEncoding $parameters)
  • SimpleUrl $url: Target to fetch as url object.
  • SimpleFormEncoding $parameters: POST/GET parameters.
  • $encoding
_createRoute (line 308)

Sets up either a direct route or via a proxy.

  • return: Route to take to fetch URL.
  • access: protected
SimpleRoute &_createRoute (SimpleUrl $url)
  • SimpleUrl $url: Target to fetch as url object.
_fetch (line 267)

Actually make the web request.

  • return: Headers and hopefully content.
  • access: protected
SimpleHttpResponse &_fetch (SimpleUrl $url, SimpleFormEncoding $encoding)
  • SimpleUrl $url: Target to fetch.
  • SimpleFormEncoding $encoding: Additional parameters for request.

Documentation generated on Sun, 04 May 2008 09:22:24 -0500 by phpDocumentor 1.3.0