Starts with no cookies, realms or proxies.
SimpleUserAgent
SimpleUserAgent
()
Adds a header to every fetch.
void
addHeader
(string $header)
-
string
$header: Header line to add to every request until cleared.
Ages the cookies by the specified time.
void
ageCookies
(integer $interval)
-
integer
$interval: Amount in seconds.
Turns an incoming URL string or object into a URL object, filling the relative URL if a base URL is present.
SimpleUrl
createAbsoluteUrl
(
string/SimpleUrl $base,
string/SimpleUrl $url)
-
string/SimpleUrl
$base: Browser current URL.
-
string/SimpleUrl
$url: Incoming URL.
Fetches a URL as a response object. Will keep trying if redirected.
It will also collect authentication realm information.
SimpleHttpResponse
&fetchResponse
(
string $method,
string/SimpleUrl $url, [
hash $parameters =
false])
-
string
$method: GET, POST, etc.
-
string/SimpleUrl
$url: Target to fetch.
-
hash
$parameters: Additional parameters for request.
Fetches a response whilst preserving the base URL.
Useful for HEAD fetches and images and frames.
SimpleHttpResponse
&fetchResponsePreservingBase
(
string $method,
string/SimpleUrl $url, [
hash $parameters =
false])
-
string
$method: GET, POST, etc.
-
string/SimpleUrl
$url: Target to fetch.
-
hash
$parameters: Additional parameters for request.
Reads the current cookies for the base URL.
string
getBaseCookieValue
(string $name)
-
string
$name: Key of cookie to find.
Accessor for base URL worked out from the current URL.
string
getBaseUrl
()
Reads the most specific cookie value from the browser cookies.
string
getCookieValue
(string $host, string $path, string $name)
-
string
$host: Host to search.
-
string
$path: Applicable path.
-
string
$name: Name of cookie to read.
Removes expired and temporary cookies as if the browser was closed and re-opened.
void
restartSession
([string/integer $date = false])
-
string/integer
$date: Time when session restarted. If omitted then all persistent cookies are kept.
Sets the current location.
Sets the socket timeout for opening a connection.
void
setConnectionTimeout
(integer $timeout)
-
integer
$timeout: Maximum time in seconds.
Sets an additional cookie. If a cookie has the same name and path it is replaced.
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.
Sets the identity for the current realm.
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.
Sets the maximum number of redirects before a page will be loaded anyway.
void
setMaximumRedirects
(integer $max)
-
integer
$max: Most hops allowed.
Sets proxy to use on all requests for when testing from behind a firewall. Set URL to false to disable.
void
useProxy
(string $proxy, string $username, string $password)
-
string
$proxy: Proxy URL.
-
string
$username: Proxy username for authentication.
-
string
$password: Proxy password for authentication.
Adds additional manual headers.
Extracts new cookies into the cookie jar.
void
_addCookiesToJar
(
SimpleUrl $url,
array $cookies)
-
SimpleUrl
$url: Target to fetch as url object.
-
array
$cookies: New cookies.
Builds the appropriate HTTP request object.
-
string
$method: Fetching method.
-
SimpleUrl
$url: Target to fetch as url object.
-
hash
$parameters: POST/GET parameters.
Creates a full page request.
-
string
$method: Fetching method.
-
SimpleUrl
$url: Target to fetch as url object.
-
hash
$parameters: POST/GET parameters.
Sets up either a direct route or via a proxy.
-
SimpleUrl
$url: Target to fetch as url object.
Actually make the web request.
-
string
$method: GET, POST, etc.
-
SimpleUrl
$url: Target to fetch.
-
hash
$parameters: Additional parameters for request.
Fetches the page until no longer redirected or until the redirect limit runs out.
SimpleHttpResponse
&_fetchWhileRedirected
(
string $method,
string/SimpleUrl $url,
hash $parameters)
-
string
$method: GET, POST, etc.
-
string/SimpleUrl
$url: Target to fetch.
-
hash
$parameters: Additional parameters for request.
Test to see if the redirect limit is passed.
boolean
_isTooManyRedirects
(integer $redirects)
-
integer
$redirects: Count so far.