PHP 클래스 SimpleUserAgent, simpletest

@package SimpleTest
파일 보기 프로젝트 열기: simpletest/simpletest 1 사용 예제들

공개 메소드들

메소드 설명
__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.

보호된 메소드들

메소드 설명
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.

메소드 상세

__construct() 공개 메소드

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

addAdditionalHeaders() 보호된 메소드

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

addHeader() 공개 메소드

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

ageCookies() 공개 메소드

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

createHttpRequest() 보호된 메소드

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

createRequest() 보호된 메소드

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.
리턴 SimpleHttpRequest New request.

createRoute() 보호된 메소드

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

fetch() 보호된 메소드

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

fetchResponse() 공개 메소드

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

fetchWhileRedirected() 보호된 메소드

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.
리턴 SimpleHttpResponse Hopefully the target page.

getBaseCookieValue() 공개 메소드

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.
리턴 string/boolean

getCookieValue() 공개 메소드

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.
리턴 string False if not present, else the value as a string.

ignoreCookies() 공개 메소드

Switches off cookie sending and recieving.
public ignoreCookies ( )

isTooManyRedirects() 보호된 메소드

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

restart() 공개 메소드

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

setConnectionTimeout() 공개 메소드

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

setCookie() 공개 메소드

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() 공개 메소드

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() 공개 메소드

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

setReferer() 공개 메소드

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() 공개 메소드

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

useProxy() 공개 메소드

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.