PHP Class SimpleUserAgent, simpletest

@package SimpleTest
Afficher le fichier Open project: simpletest/simpletest Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( ) Starts with no cookies, realms or proxies.
addHeader ( string $header ) Adds a header to every fetch.
ageCookies ( integer $interval ) Ages the cookies by the specified time.
fetchResponse ( string/SimpleUrl $url, SimpleEncoding $encoding ) : SimpleHttpResponse Fetches a URL as a response object. Will keep trying if redirected.
getBaseCookieValue ( string $name, SimpleUrl $base ) : string/boolean Reads the current cookies within the base URL.
getCookieValue ( string $host, string $path, string $name ) : string Reads the most specific cookie value from the browser cookies.
ignoreCookies ( ) Switches off cookie sending and recieving.
restart ( string/integer $date = false ) Removes expired and temporary cookies as if the browser was closed and re-opened.
setConnectionTimeout ( integer $timeout ) Sets the socket timeout for opening a connection.
setCookie ( string $name, string $value, string $host = false, string $path = '/', string $expiry = false ) Sets an additional cookie. If a cookie has the same name and path it is replaced.
setIdentity ( string $host, string $realm, string $username, string $password ) Sets the identity for the current realm.
setMaximumRedirects ( integer $max ) Sets the maximum number of redirects before a page will be loaded anyway.
setReferer ( string $referer ) Sets the referrer to send with the request, as long as it is not set explicitely via {@link addHeader()}.
useCookies ( ) Switches back on the cookie sending and recieving.
useProxy ( string $proxy, string $username, string $password ) Sets proxy to use on all requests for when testing from behind a firewall.

Méthodes protégées

Méthode Description
addAdditionalHeaders ( SimpleHttpRequest &$request ) Adds additional manual headers.
createHttpRequest ( SimpleUrl $url, $encoding ) : SimpleHttpRequest Builds the appropriate HTTP request object.
createRequest ( SimpleUrl $url, SimpleFormEncoding $encoding ) : SimpleHttpRequest Creates a full page request.
createRoute ( SimpleUrl $url ) : SimpleRoute Sets up either a direct route or via a proxy.
fetch ( SimpleUrl $url, SimpleFormEncoding $encoding ) : SimpleHttpResponse Actually make the web request.
fetchWhileRedirected ( SimpleUrl $url, SimpelFormEncoding $encoding ) : SimpleHttpResponse Fetches the page until no longer redirected or until the redirect limit runs out.
isTooManyRedirects ( integer $redirects ) : boolean Test to see if the redirect limit is passed.

Method Details

__construct() public méthode

Starts with no cookies, realms or proxies.
public __construct ( )

addAdditionalHeaders() protected méthode

Adds additional manual headers.
protected addAdditionalHeaders ( SimpleHttpRequest &$request )
$request SimpleHttpRequest Outgoing request.

addHeader() public méthode

Adds a header to every fetch.
public addHeader ( string $header )
$header string Header line to add to every request until cleared.

ageCookies() public méthode

Ages the cookies by the specified time.
public ageCookies ( integer $interval )
$interval integer Amount in seconds.

createHttpRequest() protected méthode

Builds the appropriate HTTP request object.
protected createHttpRequest ( SimpleUrl $url, $encoding ) : SimpleHttpRequest
$url SimpleUrl Target to fetch as url object.
Résultat SimpleHttpRequest New request object.

createRequest() protected méthode

Creates a full page request.
protected createRequest ( SimpleUrl $url, SimpleFormEncoding $encoding ) : SimpleHttpRequest
$url SimpleUrl Target to fetch as url object.
$encoding SimpleFormEncoding POST/GET parameters.
Résultat SimpleHttpRequest New request.

createRoute() protected méthode

Sets up either a direct route or via a proxy.
protected createRoute ( SimpleUrl $url ) : SimpleRoute
$url SimpleUrl Target to fetch as url object.
Résultat SimpleRoute Route to take to fetch URL.

fetch() protected méthode

Actually make the web request.
protected fetch ( SimpleUrl $url, SimpleFormEncoding $encoding ) : SimpleHttpResponse
$url SimpleUrl Target to fetch.
$encoding SimpleFormEncoding Additional parameters for request.
Résultat SimpleHttpResponse Headers and hopefully content.

fetchResponse() public méthode

It will also collect authentication realm information.
public fetchResponse ( string/SimpleUrl $url, SimpleEncoding $encoding ) : SimpleHttpResponse
$url string/SimpleUrl
$encoding SimpleEncoding Additional parameters for request.
Résultat SimpleHttpResponse Hopefully the target page.

fetchWhileRedirected() protected méthode

Fetches the page until no longer redirected or until the redirect limit runs out.
protected fetchWhileRedirected ( SimpleUrl $url, SimpelFormEncoding $encoding ) : SimpleHttpResponse
$url SimpleUrl Target to fetch.
$encoding SimpelFormEncoding Additional parameters for request.
Résultat SimpleHttpResponse Hopefully the target page.

getBaseCookieValue() public méthode

Reads the current cookies within the base URL.
public getBaseCookieValue ( string $name, SimpleUrl $base ) : string/boolean
$name string Key of cookie to find.
$base SimpleUrl Base URL to search from.
Résultat string/boolean

getCookieValue() public méthode

Reads the most specific cookie value from the browser cookies.
public getCookieValue ( string $host, string $path, string $name ) : string
$host string Host to search.
$path string Applicable path.
$name string Name of cookie to read.
Résultat string False if not present, else the value as a string.

ignoreCookies() public méthode

Switches off cookie sending and recieving.
public ignoreCookies ( )

isTooManyRedirects() protected méthode

Test to see if the redirect limit is passed.
protected isTooManyRedirects ( integer $redirects ) : boolean
$redirects integer Count so far.
Résultat boolean True if over.

restart() public méthode

Authorisation has to be obtained again as well.
public restart ( string/integer $date = false )
$date string/integer

setConnectionTimeout() public méthode

Sets the socket timeout for opening a connection.
public setConnectionTimeout ( integer $timeout )
$timeout integer Maximum time in seconds.

setCookie() public méthode

Sets an additional cookie. If a cookie has the same name and path it is replaced.
public setCookie ( string $name, string $value, string $host = false, string $path = '/', string $expiry = false )
$name string Cookie key.
$value string Value of cookie.
$host string Host upon which the cookie is valid.
$path string Cookie path if not host wide.
$expiry string Expiry date.

setIdentity() public méthode

Sets the identity for the current realm.
public setIdentity ( string $host, string $realm, string $username, string $password )
$host string Host to which realm applies.
$realm string Full name of realm.
$username string Username for realm.
$password string Password for realm.

setMaximumRedirects() public méthode

Sets the maximum number of redirects before a page will be loaded anyway.
public setMaximumRedirects ( integer $max )
$max integer Most hops allowed.

setReferer() public méthode

Sets the referrer to send with the request, as long as it is not set explicitely via {@link addHeader()}.
public setReferer ( string $referer )
$referer string Referer URI to add to every request until cleared.

useCookies() public méthode

Switches back on the cookie sending and recieving.
public useCookies ( )

useProxy() public méthode

Set URL to false to disable.
public useProxy ( string $proxy, string $username, string $password )
$proxy string Proxy URL.
$username string Proxy username for authentication.
$password string Proxy password for authentication.