diff --git a/src/PhpEnvironment/Request.php b/src/PhpEnvironment/Request.php index 03d9e7af3a..6aa733a122 100644 --- a/src/PhpEnvironment/Request.php +++ b/src/PhpEnvironment/Request.php @@ -266,8 +266,9 @@ public function setServer(ParametersInterface $server) $port = null; // Set the host - if ($this->getHeaders()->get('host')) { - $host = $this->getHeaders()->get('host')->getFieldValue(); + $headerHost = $this->getHeaders()->get('host'); + if ($headerHost) { + $host = $headerHost->getFieldValue(); // works for regname, IPv4 & IPv6 if (preg_match('|\:(\d+)$|', $host, $matches)) {