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; }
/** * Check that invalid hosts are invalid according to validateHost() * * @param string $host * @dataProvider invalidHostProvider */ public function testValidateHostInvalid($host) { $this->assertFalse(Uri::validateHost($host)); }
/** * 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; }