fixes from scrutinizer-ci
This commit is contained in:
@@ -241,7 +241,7 @@ class Request
|
||||
|
||||
private static function getArrayFromQuerystring($query)
|
||||
{
|
||||
$query = preg_replace_callback('/(?:^|(?<=&))[^=[]+/', function($match) {
|
||||
$query = preg_replace_callback('/(?:^|(?<=&))[^=[]+/', function ($match) {
|
||||
return bin2hex(urldecode($match[0]));
|
||||
}, $query);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class Response
|
||||
public function __construct($code, $raw_body, $headers)
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->headers = http_parse_headers($headers);
|
||||
$this->headers = $this->parseHeaders($headers);
|
||||
$this->raw_body = $raw_body;
|
||||
$this->body = $raw_body;
|
||||
$json = json_decode($raw_body);
|
||||
@@ -27,41 +27,44 @@ class Response
|
||||
$this->body = $json;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if PECL_HTTP is not available use a fall back function
|
||||
*
|
||||
* thanks to ricardovermeltfoort@gmail.com
|
||||
* http://php.net/manual/en/function.http-parse-headers.php#112986
|
||||
*/
|
||||
if (!function_exists('http_parse_headers')) {
|
||||
function http_parse_headers($raw_headers) {
|
||||
$headers = array();
|
||||
$key = '';
|
||||
/**
|
||||
* if PECL_HTTP is not available use a fall back function
|
||||
*
|
||||
* thanks to ricardovermeltfoort@gmail.com
|
||||
* http://php.net/manual/en/function.http-parse-headers.php#112986
|
||||
*/
|
||||
private function parseHeaders($raw_headers) {
|
||||
if (function_exists('http_parse_headers')) {
|
||||
return http_parse_headers($raw_headers);
|
||||
} else {
|
||||
|
||||
foreach(explode("\n", $raw_headers) as $i => $h) {
|
||||
$h = explode(':', $h, 2);
|
||||
$headers = array();
|
||||
$key = '';
|
||||
|
||||
if (isset($h[1])) {
|
||||
if (!isset($headers[$h[0]])) {
|
||||
$headers[$h[0]] = trim($h[1]);
|
||||
} elseif (is_array($headers[$h[0]])) {
|
||||
$headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));
|
||||
foreach (explode("\n", $raw_headers) as $i => $h) {
|
||||
$h = explode(':', $h, 2);
|
||||
|
||||
if (isset($h[1])) {
|
||||
if (!isset($headers[$h[0]])) {
|
||||
$headers[$h[0]] = trim($h[1]);
|
||||
} elseif (is_array($headers[$h[0]])) {
|
||||
$headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));
|
||||
} else {
|
||||
$headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));
|
||||
}
|
||||
|
||||
$key = $h[0];
|
||||
} else {
|
||||
$headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));
|
||||
}
|
||||
|
||||
$key = $h[0];
|
||||
} else {
|
||||
if (substr($h[0], 0, 1) == "\t") {
|
||||
$headers[$key] .= "\r\n\t".trim($h[0]);
|
||||
} elseif (!$key){
|
||||
$headers[0] = trim($h[0]);
|
||||
if (substr($h[0], 0, 1) == "\t") {
|
||||
$headers[$key] .= "\r\n\t".trim($h[0]);
|
||||
} elseif (!$key) {
|
||||
$headers[0] = trim($h[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $headers;
|
||||
return $headers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user