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 { 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 +}