📄 browser.php.svn-base
字号:
* @access public */ function ageCookies($interval) { $this->_user_agent->ageCookies($interval); } /** * Sets an additional cookie. If a cookie has * the same name and path it is replaced. * @param string $name Cookie key. * @param string $value Value of cookie. * @param string $host Host upon which the cookie is valid. * @param string $path Cookie path if not host wide. * @param string $expiry Expiry date. * @access public */ function setCookie($name, $value, $host = false, $path = '/', $expiry = false) { $this->_user_agent->setCookie($name, $value, $host, $path, $expiry); } /** * Reads the most specific cookie value from the * browser cookies. * @param string $host Host to search. * @param string $path Applicable path. * @param string $name Name of cookie to read. * @return string False if not present, else the * value as a string. * @access public */ function getCookieValue($host, $path, $name) { return $this->_user_agent->getCookieValue($host, $path, $name); } /** * Reads the current cookies for the current URL. * @param string $name Key of cookie to find. * @return string Null if there is no current URL, false * if the cookie is not set. * @access public */ function getCurrentCookieValue($name) { return $this->_user_agent->getBaseCookieValue($name, $this->_page->getUrl()); } /** * Sets the maximum number of redirects before * a page will be loaded anyway. * @param integer $max Most hops allowed. * @access public */ function setMaximumRedirects($max) { $this->_user_agent->setMaximumRedirects($max); } /** * Sets the maximum number of nesting of framed pages * within a framed page to prevent loops. * @param integer $max Highest depth allowed. * @access public */ function setMaximumNestedFrames($max) { $this->_maximum_nested_frames = $max; } /** * Sets the socket timeout for opening a connection. * @param integer $timeout Maximum time in seconds. * @access public */ function setConnectionTimeout($timeout) { $this->_user_agent->setConnectionTimeout($timeout); } /** * Sets proxy to use on all requests for when * testing from behind a firewall. Set URL * to false to disable. * @param string $proxy Proxy URL. * @param string $username Proxy username for authentication. * @param string $password Proxy password for authentication. * @access public */ function useProxy($proxy, $username = false, $password = false) { $this->_user_agent->useProxy($proxy, $username, $password); } /** * Fetches the page content with a HEAD request. * Will affect cookies, but will not change the base URL. * @param string/SimpleUrl $url Target to fetch as string. * @param hash/SimpleHeadEncoding $parameters Additional parameters for * HEAD request. * @return boolean True if successful. * @access public */ function head($url, $parameters = false) { if (! is_object($url)) { $url = new SimpleUrl($url); } if ($this->getUrl()) { $url = $url->makeAbsolute($this->getUrl()); } $response = &$this->_user_agent->fetchResponse($url, new SimpleHeadEncoding($parameters)); return ! $response->isError(); } /** * Fetches the page content with a simple GET request. * @param string/SimpleUrl $url Target to fetch. * @param hash/SimpleFormEncoding $parameters Additional parameters for * GET request. * @return string Content of page or false. * @access public */ function get($url, $parameters = false) { if (! is_object($url)) { $url = new SimpleUrl($url); } if ($this->getUrl()) { $url = $url->makeAbsolute($this->getUrl()); } return $this->_load($url, new SimpleGetEncoding($parameters)); } /** * Fetches the page content with a POST request. * @param string/SimpleUrl $url Target to fetch as string. * @param hash/SimpleFormEncoding $parameters POST parameters. * @return string Content of page. * @access public */ function post($url, $parameters = false) { if (! is_object($url)) { $url = new SimpleUrl($url); } if ($this->getUrl()) { $url = $url->makeAbsolute($this->getUrl()); } return $this->_load($url, new SimplePostEncoding($parameters)); } /** * Equivalent to hitting the retry button on the * browser. Will attempt to repeat the page fetch. If * there is no history to repeat it will give false. * @return string/boolean Content if fetch succeeded * else false. * @access public */ function retry() { $frames = $this->_page->getFrameFocus(); if (count($frames) > 0) { $this->_loadFrame( $frames, $this->_page->getUrl(), $this->_page->getRequestData()); return $this->_page->getRaw(); } if ($url = $this->_history->getUrl()) { $this->_page = &$this->_fetch($url, $this->_history->getParameters()); return $this->_page->getRaw(); } return false; } /** * Equivalent to hitting the back button on the * browser. The browser history is unchanged on * failure. The page content is refetched as there * is no concept of content caching in SimpleTest. * @return boolean True if history entry and * fetch succeeded * @access public */ function back() { if (! $this->_history->back()) { return false; } $content = $this->retry(); if (! $content) { $this->_history->forward(); } return $content; } /** * Equivalent to hitting the forward button on the * browser. The browser history is unchanged on * failure. The page content is refetched as there * is no concept of content caching in SimpleTest. * @return boolean True if history entry and * fetch succeeded * @access public */ function forward() { if (! $this->_history->forward()) { return false; } $content = $this->retry(); if (! $content) { $this->_history->back(); } return $content; } /** * Retries a request after setting the authentication * for the current realm. * @param string $username Username for realm. * @param string $password Password for realm. * @return boolean True if successful fetch. Note * that authentication may still have * failed. * @access public */ function authenticate($username, $password) { if (! $this->_page->getRealm()) { return false; } $url = $this->_page->getUrl(); if (! $url) { return false; } $this->_user_agent->setIdentity( $url->getHost(), $this->_page->getRealm(), $username, $password); return $this->retry(); } /** * Accessor for a breakdown of the frameset. * @return array Hash tree of frames by name * or index if no name. * @access public */ function getFrames() { return $this->_page->getFrames(); } /** * Accessor for current frame focus. Will be * false if no frame has focus. * @return integer/string/boolean Label if any, otherwise * the position in the frameset * or false if none. * @access public */ function getFrameFocus() { return $this->_page->getFrameFocus(); } /** * Sets the focus by index. The integer index starts from 1. * @param integer $choice Chosen frame. * @return boolean True if frame exists. * @access public */ function setFrameFocusByIndex($choice) { return $this->_page->setFrameFocusByIndex($choice); } /** * Sets the focus by name. * @param string $name Chosen frame. * @return boolean True if frame exists. * @access public */ function setFrameFocus($name) { return $this->_page->setFrameFocus($name); } /** * Clears the frame focus. All frames will be searched * for content. * @access public */ function clearFrameFocus() { return $this->_page->clearFrameFocus(); } /** * Accessor for last error. * @return string Error from last response. * @access public */ function getTransportError() { return $this->_page->getTransportError(); } /** * Accessor for current MIME type. * @return string MIME type as string; e.g. 'text/html' * @access public */ function getMimeType() { return $this->_page->getMimeType(); } /** * Accessor for last response code. * @return integer Last HTTP response code received. * @access public */ function getResponseCode() { return $this->_page->getResponseCode(); } /** * Accessor for last Authentication type. Only valid * straight after a challenge (401). * @return string Description of challenge type. * @access public */ function getAuthentication() { return $this->_page->getAuthentication(); } /** * Accessor for last Authentication realm. Only valid * straight after a challenge (401). * @return string Name of security realm. * @access public */ function getRealm() { return $this->_page->getRealm(); } /** * Accessor for current URL of page or frame if * focused. * @return string Location of current page or frame as * a string. */ function getUrl() { $url = $this->_page->getUrl(); return $url ? $url->asString() : false; } /** * Accessor for base URL of page if set via BASE tag * @return string base URL */ function getBaseUrl() { $url = $this->_page->getBaseUrl(); return $url ? $url->asString() : false; } /** * Accessor for raw bytes sent down the wire. * @return string Original text sent. * @access public */ function getRequest() { return $this->_page->getRequest(); } /** * Accessor for raw header information. * @return string Header block. * @access public */ function getHeaders() { return $this->_page->getHeaders();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -