@@ -10,7 +10,7 @@ public function __construct()
1010 $ this ->apiHost = "https://codeclimate.com " ;
1111
1212 if (isset ($ _SERVER ["CODECLIMATE_API_HOST " ])) {
13- $ this ->apiHost = $ _SERVER ["CODECLIMATE_API_HOST " ];
13+ $ this ->apiHost = $ _SERVER ["CODECLIMATE_API_HOST " ];
1414 }
1515
1616 }
@@ -19,29 +19,37 @@ public function send($json)
1919 {
2020 $ ch = curl_init ();
2121 curl_setopt_array ($ ch , array (
22- CURLOPT_CUSTOMREQUEST => 'POST ' ,
23- CURLOPT_URL => $ this ->apiHost .'/test_reports ' ,
24- CURLOPT_USERAGENT => 'Code Climate (PHP Test Reporter v ' .Version::VERSION .') ' ,
25- CURLOPT_HTTPHEADER => array ('Content-Type: application/json ' ),
26- CURLOPT_HEADER => true ,
27- CURLOPT_RETURNTRANSFER => true ,
28- CURLOPT_POSTFIELDS => (string )$ json ,
22+ CURLOPT_CUSTOMREQUEST => 'POST ' ,
23+ CURLOPT_URL => $ this ->apiHost .'/test_reports ' ,
24+ CURLOPT_USERAGENT => 'Code Climate (PHP Test Reporter v ' .Version::VERSION .') ' ,
25+ CURLOPT_HTTPHEADER => array ('Content-Type: application/json ' ),
26+ CURLOPT_HEADER => true ,
27+ CURLOPT_RETURNTRANSFER => true ,
28+ CURLOPT_POSTFIELDS => (string )$ json ,
2929 ));
3030
3131 $ response = new \stdClass ;
3232 if ($ raw_response = curl_exec ($ ch )) {
33- list ($ response ->headers , $ response ->body ) = explode ("\r\n\r\n" , $ raw_response , 2 );
34- $ response ->headers = explode ("\r\n" , $ response ->headers );
35- list (, $ response ->code , $ response ->message ) = explode (' ' , $ response ->headers [0 ], 3 );
36- }
37- else {
38- $ response ->code = -curl_errno ($ ch );
39- $ response ->message = curl_error ($ ch );
40- $ response ->headers = array ();
41- $ response ->body = NULL ;
33+ $ this ->buildResponse ($ response , $ raw_response );
34+
35+ while ($ response ->code == 100 ) { // Continue
36+ $ this ->buildResponse ($ response , $ response ->body );
37+ }
38+ } else {
39+ $ response ->code = -curl_errno ($ ch );
40+ $ response ->message = curl_error ($ ch );
41+ $ response ->headers = array ();
42+ $ response ->body = NULL ;
4243 }
4344 curl_close ($ ch );
4445
4546 return $ response ;
4647 }
48+
49+ private function buildResponse ($ response , $ body )
50+ {
51+ list ($ response ->headers , $ response ->body ) = explode ("\r\n\r\n" , $ body , 2 );
52+ $ response ->headers = explode ("\r\n" , $ response ->headers );
53+ list (, $ response ->code , $ response ->message ) = explode (' ' , $ response ->headers [0 ], 3 );
54+ }
4755}
0 commit comments