/** * Sets the host based on the current URI. */ private function setHostFromUri() { $this->hostFromUri = true; $host = $this->uri->getHost(); if (!empty($host)) { // Do not set Host header if URI has no host. $port = $this->uri->getPort(); if (null !== $port) { $host = sprintf('%s:%d', $host, $port); } parent::setHeader('Host', $host); } }
public function testCanStoreEmptyHeaders() { $this->mock->setHeader('Content-Length', 0); $this->assertTrue($this->mock->hasHeader('Content-Length')); $this->assertEquals(0, (string) $this->mock->getHeader('Content-Length')); }