File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -70,8 +70,7 @@ $curl->get('https://www.example.com/');
70
70
71
71
if ($curl->error) {
72
72
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
73
- }
74
- else {
73
+ } else {
75
74
echo $curl->response;
76
75
}
77
76
@@ -149,7 +148,8 @@ $multi_curl = new MultiCurl();
149
148
150
149
$multi_curl->success(function($instance) {
151
150
echo 'call to "' . $instance->url . '" was successful.' . "\n";
152
- echo 'response: ' . $instance->response . "\n";
151
+ echo 'response:' . "\n";
152
+ var_dump($instance->response);
153
153
});
154
154
$multi_curl->error(function($instance) {
155
155
echo 'call to "' . $instance->url . '" was unsuccessful.' . "\n";
Original file line number Diff line number Diff line change @@ -204,6 +204,7 @@ public function close()
204
204
$ this ->options = null ;
205
205
$ this ->jsonDecoder = null ;
206
206
$ this ->xmlDecoder = null ;
207
+ $ this ->defaultDecoder = null ;
207
208
}
208
209
209
210
/**
@@ -340,11 +341,18 @@ public function exec($ch = null)
340
341
$ this ->call ($ this ->beforeSendFunction );
341
342
$ this ->rawResponse = curl_exec ($ this ->curl );
342
343
$ this ->curlErrorCode = curl_errno ($ this ->curl );
344
+ $ this ->curlErrorMessage = curl_error ($ this ->curl );
343
345
} else {
344
346
$ this ->rawResponse = curl_multi_getcontent ($ ch );
347
+ $ this ->curlErrorMessage = curl_error ($ ch );
345
348
}
346
- $ this ->curlErrorMessage = curl_error ($ this ->curl );
347
349
$ this ->curlError = !($ this ->curlErrorCode === 0 );
350
+
351
+ // Include additional error code information in error message when possible.
352
+ if ($ this ->curlError && function_exists ('curl_strerror ' )) {
353
+ $ this ->curlErrorMessage = curl_strerror ($ this ->curlErrorCode ) . ': ' . $ this ->curlErrorMessage ;
354
+ }
355
+
348
356
$ this ->httpStatusCode = $ this ->getInfo (CURLINFO_HTTP_CODE );
349
357
$ this ->httpError = in_array (floor ($ this ->httpStatusCode / 100 ), array (4 , 5 ));
350
358
$ this ->error = $ this ->curlError || $ this ->httpError ;
Original file line number Diff line number Diff line change @@ -536,6 +536,9 @@ public function start()
536
536
if ($ info_array ['msg ' ] === CURLMSG_DONE ) {
537
537
foreach ($ this ->curls as $ key => $ ch ) {
538
538
if ($ ch ->curl === $ info_array ['handle ' ]) {
539
+ // Set the error code for multi handles using the "result" key in the array returned by
540
+ // curl_multi_info_read(). Using curl_errno() on a multi handle will incorrectly return 0
541
+ // for errors.
539
542
$ ch ->curlErrorCode = $ info_array ['result ' ];
540
543
$ ch ->exec ($ ch ->curl );
541
544
curl_multi_remove_handle ($ this ->multiCurl , $ ch ->curl );
You can’t perform that action at this time.
0 commit comments