diff --git a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Request.php b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Request.php index fab7eb93aabf8..a3b55f8ebfc14 100644 --- a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Request.php +++ b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Request.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Framework\HTTP\PhpEnvironment; use Magento\Framework\App\Filesystem\DirectoryList; @@ -25,7 +26,7 @@ class Request extends \Laminas\Http\PhpEnvironment\Request /**#@+ * Protocols */ - const SCHEME_HTTP = 'http'; + const SCHEME_HTTP = 'http'; const SCHEME_HTTPS = 'https'; /**#@-*/ @@ -123,7 +124,7 @@ public function __construct( $uri = UriFactory::factory($uri); } if ($uri->isValid()) { - $path = $uri->getPath(); + $path = $uri->getPath(); $query = $uri->getQuery(); if (!empty($query)) { $path .= '?' . $query; @@ -302,7 +303,7 @@ public function setAlias($name, $target) */ public function getParam($key, $default = null) { - $key = (string) $key; + $key = (string)$key; $keyName = (null !== ($alias = $this->getAlias($key))) ? $alias : $key; if (isset($this->params[$keyName])) { return $this->params[$keyName]; @@ -325,7 +326,7 @@ public function getParam($key, $default = null) */ public function setParam($key, $value) { - $key = (string) $key; + $key = (string)$key; $keyName = (null !== ($alias = $this->getAlias($key))) ? $alias : $key; if ((null === $value) && isset($this->params[$keyName])) { unset($this->params[$keyName]); @@ -696,7 +697,7 @@ public function getHeader($name, $default = false) if ($header instanceof HeaderInterface) { return $header->getFieldValue(); } - return false; + return $header; } /** @@ -724,7 +725,7 @@ public function getHttpHost($trimPort = true) /** * Get the client's IP addres * - * @param boolean $checkProxy + * @param boolean $checkProxy * @return string */ public function getClientIp($checkProxy = true) @@ -795,7 +796,7 @@ public function setRequestUri($requestUri = null) public function getBaseUrl() { $url = urldecode(parent::getBaseUrl()); - $url = str_replace(['\\', '/' . DirectoryList::PUB .'/'], '/', $url); + $url = str_replace(['\\', '/' . DirectoryList::PUB . '/'], '/', $url); return $url; } diff --git a/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RequestTest.php b/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RequestTest.php index 4ddb59ed38093..858820204488d 100644 --- a/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RequestTest.php +++ b/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RequestTest.php @@ -280,4 +280,24 @@ public function testGetCookieNullName() $this->assertEquals($default, $this->getModel()->getCookie($nullKey, $default)); } + + /** + * Get header with default value test + */ + public function testGetHeaderWithDefaultValue() + { + $expectedValue = 'test-value'; + $actualValue = $this->getModel()->getHeader('test-header', $expectedValue); + $this->assertEquals($expectedValue, $actualValue); + } + + /** + * Get header without default value test + */ + public function testGetHeaderWithoutDefaultValue() + { + $expectedValue = false; + $actualValue = $this->getModel()->getHeader('test-header'); + $this->assertEquals($expectedValue, $actualValue); + } }