Exemplo n.º 1
0
 public static function fromString($headerLine)
 {
     $header = new static();
     list($name, $value) = explode(': ', $headerLine, 2);
     // check to ensure proper header type for this factory
     if (strtolower($name) !== 'location') {
         throw new Exception\InvalidArgumentException('Invalid header line for Location string: "' . $name . '"');
     }
     if (!Uri::validateHost($value)) {
         throw new Exception\InvalidArgumentException('Invalid URI value for Location: "' . $value . '"');
     }
     // @todo implementation details
     $header->value = $value;
     return $header;
 }
Exemplo n.º 2
0
 /**
  * Check that invalid hosts are invalid according to validateHost()
  *
  * @param string $host
  * @dataProvider invalidHostProvider
  */
 public function testValidateHostInvalid($host)
 {
     $this->assertFalse(Uri::validateHost($host));
 }
Exemplo n.º 3
0
 /**
  * Set the URI/URL for this request, this can be a string or an instance of Zend\Uri\Http
  *
  * @throws Exception\InvalidArgumentException
  * @param string|HttpUri $uri
  * @return Request
  */
 public function setUri($uri)
 {
     if (is_string($uri)) {
         if (!\Zend\Uri\Uri::validateHost($uri)) {
             throw new Exception\InvalidArgumentException('Invalid URI passed as string');
         }
     } elseif (!$uri instanceof \Zend\Uri\Http) {
         throw new Exception\InvalidArgumentException('URI must be an instance of Zend\\Uri\\Http or a string');
     }
     $this->uri = $uri;
     return $this;
 }