fixes #24
allows for an extra param to decode json objects into associative arrays
This commit is contained in:
@@ -15,13 +15,13 @@ class HttpResponse
|
|||||||
* @param string $raw_body the raw body of the cURL response
|
* @param string $raw_body the raw body of the cURL response
|
||||||
* @param string $headers raw header string from cURL response
|
* @param string $headers raw header string from cURL response
|
||||||
*/
|
*/
|
||||||
public function __construct($code, $raw_body, $headers)
|
public function __construct($code, $raw_body, $headers, $json_decode_assoc = false)
|
||||||
{
|
{
|
||||||
$this->code = $code;
|
$this->code = $code;
|
||||||
$this->headers = $this->get_headers_from_curl_response($headers);
|
$this->headers = $this->get_headers_from_curl_response($headers);
|
||||||
$this->raw_body = $raw_body;
|
$this->raw_body = $raw_body;
|
||||||
$this->body = $raw_body;
|
$this->body = $raw_body;
|
||||||
$json = json_decode($raw_body);
|
$json = json_decode($raw_body, $json_decode_assoc);
|
||||||
|
|
||||||
if (json_last_error() == JSON_ERROR_NONE) {
|
if (json_last_error() == JSON_ERROR_NONE) {
|
||||||
$this->body = $json;
|
$this->body = $json;
|
||||||
|
|||||||
Reference in New Issue
Block a user