/** * 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); } }