コード例 #1
0
 /**
  * Returns an instance with the provided URI.
  *
  * @param  UriInterface $uri          New request URI to use.
  * @param  bool         $preserveHost Preserve the original state of the Host header.
  * @access public
  * @return self
  */
 public function withUri(UriInterface $uri, $preserveHost = false)
 {
     $this->uri = $uri;
     $host = $this->uri->getHost();
     if ($preserveHost) {
         if ($host != '' && !$this->hasHeader('Host')) {
             $this->withHeader('Host', $host);
         }
         return $this;
     }
     if ($host != '') {
         $this->withHeader('Host', $host);
     }
     return $this;
 }
コード例 #2
0
ファイル: URITest.php プロジェクト: titounnes/CodeIgniter4
 public function testSetHostSetsValue()
 {
     $url = 'http://example.com/path';
     $uri = new URI($url);
     $expected = 'http://another.com/path';
     $uri->setHost('another.com');
     $this->assertEquals('another.com', $uri->getHost());
     $this->assertEquals($expected, (string) $uri);
 }