/** * Fetches a URL as a response object. Will keep trying if redirected. * It will also collect authentication realm information. * @param string/SimpleUrl $url Target to fetch. * @param SimpleEncoding $encoding Additional parameters for request. * @return SimpleHttpResponse Hopefully the target page. * @access public */ function fetchResponse($url, $encoding) { if ($encoding->getMethod() != 'POST') { $url->addRequestParameters($encoding); $encoding->clear(); } $response = $this->fetchWhileRedirected($url, $encoding); if ($headers = $response->getHeaders()) { if ($headers->isChallenge()) { $this->authenticator->addRealm($url, $headers->getAuthentication(), $headers->getRealm()); } } return $response; }
/** * Fetches a URL as a response object. Will keep trying if redirected. * It will also collect authentication realm information. * @param string $method GET, POST, etc. * @param string/SimpleUrl $url Target to fetch. * @param SimpleFormEncoding $parameters Additional parameters for request. * @return SimpleHttpResponse Hopefully the target page. * @access public */ function &fetchResponse($method, $url, $parameters = false) { if ($method != 'POST') { $url->addRequestParameters($parameters); $parameters = false; } $response =& $this->_fetchWhileRedirected($method, $url, $parameters); if ($headers = $response->getHeaders()) { if ($headers->isChallenge()) { $this->_authenticator->addRealm($url, $headers->getAuthentication(), $headers->getRealm()); } } return $response; }
/** * Replaces unknown sections of the path with base parts * to return a complete absolute one. * @param string/SimpleUrl $base Base URL. * @param string Absolute path. * @access private */ function _extractAbsolutePath($base) { if ($this->getHost()) { return $this->_path; } if (!$this->_isRelativePath($this->_path)) { return $this->_path; } if ($this->_path) { return $base->getBasePath() . $this->_path; } return $base->getPath(); }
/** * Fetches a page or a single frame if that is the current * focus. * @param string $method GET or POST. * @param string/SimpleUrl $url Target to fetch as string. * @param hash $parameters POST parameters. * @return string Raw content of page. * @access private */ function _load($method, $url, $parameters = false) { $frame = $url->getTarget(); if (!$frame || strtolower($frame) == '_top') { return $this->_loadPage($method, $url, $parameters); } return $this->_loadFrame(array($frame), $method, $url, $parameters); }