@@ -10,7 +10,7 @@ public function __construct()
10
10
$ this ->apiHost = "https://codeclimate.com " ;
11
11
12
12
if (isset ($ _SERVER ["CODECLIMATE_API_HOST " ])) {
13
- $ this ->apiHost = $ _SERVER ["CODECLIMATE_API_HOST " ];
13
+ $ this ->apiHost = $ _SERVER ["CODECLIMATE_API_HOST " ];
14
14
}
15
15
16
16
}
@@ -19,29 +19,37 @@ public function send($json)
19
19
{
20
20
$ ch = curl_init ();
21
21
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 ,
29
29
));
30
30
31
31
$ response = new \stdClass ;
32
32
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 ;
42
43
}
43
44
curl_close ($ ch );
44
45
45
46
return $ response ;
46
47
}
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
+ }
47
55
}
0 commit comments