fixes from scrutinizer-ci
This commit is contained in:
@@ -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,7 +27,6 @@ class Response
|
||||
$this->body = $json;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if PECL_HTTP is not available use a fall back function
|
||||
@@ -35,8 +34,11 @@ class Response
|
||||
* 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) {
|
||||
private function parseHeaders($raw_headers) {
|
||||
if (function_exists('http_parse_headers')) {
|
||||
return http_parse_headers($raw_headers);
|
||||
} else {
|
||||
|
||||
$headers = array();
|
||||
$key = '';
|
||||
|
||||
@@ -65,3 +67,4 @@ if (!function_exists('http_parse_headers')) {
|
||||
return $headers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ class UnirestTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
Request::timeout(1);
|
||||
|
||||
$response = Request::get('http://httpbin.org/delay/3');
|
||||
Request::get('http://httpbin.org/delay/3');
|
||||
|
||||
Request::timeout(null); // Cleaning timeout for the other tests
|
||||
}
|
||||
@@ -353,7 +353,7 @@ class UnirestTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testBasicAuthentication()
|
||||
{
|
||||
$response = Request::get('http://httpbin.org/get', null, null, 'user', 'password');
|
||||
$response = Request::get('http://httpbin.org/get', null, array(), 'user', 'password');
|
||||
$headers = $response->body->headers;
|
||||
$this->assertEquals('Basic dXNlcjpwYXNzd29yZA==', $headers->Authorization);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user