Exemple #1
0
 public function testGetUrlForParameters()
 {
     $url = new Ergo_Http_Url('http://example.org/test');
     $relative = $url->getUrlForParameters(array('a' => 1, 'b' => 2, 'c' => 'test'));
     $this->assertEqual($relative->__toString(), 'http://example.org/test?a=1&b=2&c=test');
 }
Exemple #2
0
 /**
  * Redirect to a new url
  */
 private function _redirect($location)
 {
     $locationUrl = new Ergo_Http_Url($location);
     // if the location header was relative (bleh) add the host
     if (!$locationUrl->hasHost()) {
         $locationUrl = $this->_url->getUrlForPath($location);
     }
     if ($this->_redirects > self::MAX_REDIRECTS) {
         throw new Ergo_Http_Error_BadRequest("Exceeded maximum redirects");
     }
     $this->_redirects++;
     return $this->_dispatchRequest(new Ergo_Http_Request('GET', $locationUrl, $this->_headers));
 }
Exemple #3
0
 /**
  * The path of the URI, which may or may not already be path-only.
  * @param string $uri
  * @return string
  */
 private function _uriRelativeToHost($uri)
 {
     $uri = new Ergo_Http_Url($uri);
     return $uri->getHostRelativeUrl();
 }