Fix broken http header extraction in Util\Request

This commit is contained in:
Woody Gilk 2014-07-22 14:23:56 -07:00
parent f34dd4a0cb
commit 31e03c2d36

View File

@ -76,22 +76,25 @@ class Request implements RequestInterface
protected function readHeaders() protected function readHeaders()
{ {
if (function_exists('getallheaders')) { if (function_exists('apache_request_headers')) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$headers = getallheaders(); $headers = apache_request_headers();
} elseif (function_exists('http_get_request_headers')) {
$headers = http_get_request_headers();
} else { } else {
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
$headers = array(); $headers = array();
foreach ($this->server() as $name => $value) { foreach ($this->server() as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') { 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; $headers[$name] = $value;
} }
} }
} }
return $this->normalizeHeaders($headers); return $this->normalizeHeaders($headers);
} }
protected function getPropertyValue($property, $index = null, $default = null) protected function getPropertyValue($property, $index = null, $default = null)
{ {