From 31e03c2d36336121b5839fa43e9cdbf53d265282 Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Tue, 22 Jul 2014 14:23:56 -0700 Subject: [PATCH 1/2] Fix broken http header extraction in Util\Request --- src/League/OAuth2/Server/Util/Request.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/League/OAuth2/Server/Util/Request.php b/src/League/OAuth2/Server/Util/Request.php index b2f5752c..5e20923e 100644 --- a/src/League/OAuth2/Server/Util/Request.php +++ b/src/League/OAuth2/Server/Util/Request.php @@ -76,22 +76,25 @@ class Request implements RequestInterface protected function readHeaders() { - if (function_exists('getallheaders')) { + if (function_exists('apache_request_headers')) { // @codeCoverageIgnoreStart - $headers = getallheaders(); + $headers = apache_request_headers(); + } elseif (function_exists('http_get_request_headers')) { + $headers = http_get_request_headers(); } else { // @codeCoverageIgnoreEnd $headers = array(); foreach ($this->server() as $name => $value) { if (substr($name, 0, 5) == 'HTTP_') { - $name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5))))); + // HTTP_FOO_BAR becomes FOO-BAR + $name = str_replace(array('HTTP_', '_'), array('', '-'), $name); $headers[$name] = $value; } } } return $this->normalizeHeaders($headers); - } + } protected function getPropertyValue($property, $index = null, $default = null) { @@ -143,4 +146,4 @@ class Request implements RequestInterface return $key; } -} \ No newline at end of file +} From 49b776c4956e1e8bf6e21c905af3e378f6d80032 Mon Sep 17 00:00:00 2001 From: Robbie Mackay Date: Wed, 23 Jul 2014 09:51:34 +1200 Subject: [PATCH 2/2] In Resource::getExceptionHttpHeaders() use Request::BuildFromGlobals --- src/League/OAuth2/Server/Resource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/League/OAuth2/Server/Resource.php b/src/League/OAuth2/Server/Resource.php index 8eb7a91f..898a3801 100644 --- a/src/League/OAuth2/Server/Resource.php +++ b/src/League/OAuth2/Server/Resource.php @@ -165,7 +165,7 @@ class Resource // @codeCoverageIgnoreStart if ($error === 'invalid_token') { $authScheme = null; - $request = new Request(); + $request = Request::buildFromGlobals(); if ($request->server('PHP_AUTH_USER') !== null) { $authScheme = 'Basic'; } else {