Skip to content

Commit

Permalink
Use new methods internally & deprecated part of header()
Browse files Browse the repository at this point in the history
request->header() has a tricky mode where it automatically falls back to
env(). This violates the object encapsulation the request should be
trying to provide. Deprecating this behavior now allows us to make
header() a simple alias for getHeaderLine() in the future.
  • Loading branch information
markstory committed Sep 24, 2016
1 parent 7e83776 commit 6a5d9b2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Network/Request.php
Expand Up @@ -961,8 +961,13 @@ protected function normalizeHeaderName($name)
/**
* Read an HTTP header from the Request information.
*
* If the header is not defined in the request, this method
* will fallback to reading data from $_SERVER and $_ENV.
* This fallback behavior is deprecated, and will be removed in 4.0.0
*
* @param string $name Name of the header you want.
* @return string|null Either null on no header being set or the value of the header.
* @deprecated 4.0.0 The automatic fallback to env() will be removed in 4.0.0
*/
public function header($name)
{
Expand Down Expand Up @@ -1311,7 +1316,7 @@ public function accepts($type = null)
*/
public function parseAccept()
{
return $this->_parseAcceptWithQualifier($this->header('accept'));
return $this->_parseAcceptWithQualifier($this->getHeaderLine('Accept'));
}

/**
Expand All @@ -1330,7 +1335,7 @@ public function parseAccept()
*/
public function acceptLanguage($language = null)
{
$raw = $this->_parseAcceptWithQualifier($this->header('Accept-Language'));
$raw = $this->_parseAcceptWithQualifier($this->getHeaderLine('Accept-Language'));
$accept = [];
foreach ($raw as $languages) {
foreach ($languages as &$lang) {
Expand Down

0 comments on commit 6a5d9b2

Please sign in to comment.