Esempio n. 1
0
 public function testHasMethods()
 {
     $url = new Ergo_Http_Url('http://example.org/?query#fragment');
     $this->assertTrue($url->hasHost(), 'URL should have host');
     $this->assertTrue($url->hasScheme(), 'URL should have scheme');
     $this->assertTrue($url->hasQueryString(), 'URL should have query string');
     $this->assertTrue($url->hasFragmentString(), 'URL should have fragment string');
     $this->assertTrue($url->hasPort(), 'URL should have port');
     $this->assertTrue($url->hasDefaultPort(), 'URL should have default port');
     $url = new Ergo_Http_Url('/');
     $this->assertFalse($url->hasHost(), 'URL should not have host');
     $this->assertFalse($url->hasScheme(), 'URL should not have scheme');
     $this->assertFalse($url->hasQueryString(), 'URL should not have query string');
     $this->assertFalse($url->hasFragmentString(), 'URL should not have fragment string');
     $this->assertFalse($url->hasPort(), 'URL should not have port');
     $this->assertFalse($url->hasDefaultPort(), 'URL should not have default port');
 }
Esempio n. 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));
 }