@@ -35,6 +35,7 @@ class Curl
35
35
public $ request_headers = null ;
36
36
public $ response_headers = null ;
37
37
public $ response = null ;
38
+ public $ raw_response = null ;
38
39
39
40
public function __construct ()
40
41
{
@@ -311,6 +312,7 @@ private function parseRequestHeaders($raw_headers)
311
312
private function parseResponse ($ response )
312
313
{
313
314
$ response_headers = '' ;
315
+ $ raw_response = $ response ;
314
316
if (!(strpos ($ response , "\r\n\r\n" ) === false )) {
315
317
$ response_array = explode ("\r\n\r\n" , $ response );
316
318
for ($ i = count ($ response_array ) - 1 ; $ i >= 0 ; $ i --) {
@@ -325,6 +327,7 @@ private function parseResponse($response)
325
327
list ($ response_header , $ response ) = explode ("\r\n\r\n" , $ response , 2 );
326
328
}
327
329
$ response_headers = $ this ->parseResponseHeaders ($ response_header );
330
+ $ raw_response = $ response ;
328
331
329
332
if (isset ($ response_headers ['Content-Type ' ])) {
330
333
if (preg_match ('/^application\/json/i ' , $ response_headers ['Content-Type ' ])) {
@@ -344,7 +347,7 @@ private function parseResponse($response)
344
347
}
345
348
}
346
349
347
- return array ($ response_headers , $ response );
350
+ return array ($ response_headers , $ response, $ raw_response );
348
351
}
349
352
350
353
private function parseResponseHeaders ($ raw_headers )
@@ -398,9 +401,9 @@ protected function exec($_ch = null)
398
401
$ ch = is_null ($ _ch ) ? $ this : $ _ch ;
399
402
400
403
if ($ ch ->multi_child ) {
401
- $ ch ->response = curl_multi_getcontent ($ ch ->curl );
404
+ $ ch ->raw_response = curl_multi_getcontent ($ ch ->curl );
402
405
} else {
403
- $ ch ->response = curl_exec ($ ch ->curl );
406
+ $ ch ->raw_response = curl_exec ($ ch ->curl );
404
407
$ ch ->curl_error_code = curl_errno ($ ch ->curl );
405
408
}
406
409
@@ -412,7 +415,7 @@ protected function exec($_ch = null)
412
415
$ ch ->error_code = $ ch ->error ? ($ ch ->curl_error ? $ ch ->curl_error_code : $ ch ->http_status_code ) : 0 ;
413
416
414
417
$ ch ->request_headers = $ this ->parseRequestHeaders (curl_getinfo ($ ch ->curl , CURLINFO_HEADER_OUT ));
415
- list ($ ch ->response_headers , $ ch ->response ) = $ this ->parseResponse ($ ch ->response );
418
+ list ($ ch ->response_headers , $ ch ->response , $ ch -> raw_response ) = $ this ->parseResponse ($ ch ->raw_response );
416
419
417
420
$ ch ->http_error_message = '' ;
418
421
if ($ ch ->error ) {
0 commit comments