Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:thephpleague/oauth2-server into …
Browse files Browse the repository at this point in the history
…develop
  • Loading branch information
alexbilbie committed Jul 23, 2014
2 parents 6f85bcb + 00d5fb5 commit 1890d71
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/League/OAuth2/Server/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static function getExceptionHttpHeaders($error)
// @codeCoverageIgnoreStart
if ($error === 'invalid_token') {
$authScheme = null;
$request = new Request();
$request = Request::buildFromGlobals();
if ($request->server('PHP_AUTH_USER') !== null) {
$authScheme = 'Basic';
} else {
Expand Down
13 changes: 8 additions & 5 deletions src/League/OAuth2/Server/Util/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,25 @@ public function header($index = null, $default = null)

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)
{
Expand Down Expand Up @@ -143,4 +146,4 @@ protected function normalizeKey($key)

return $key;
}
}
}

0 comments on commit 1890d71

Please sign in to comment.