Skip to content

Commit e8cb0bf

Browse files
committed
Improve uses of cURL
1 parent 64ef845 commit e8cb0bf

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/Controller/Component/GithubApiComponent.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
use function array_merge;
2727
use function curl_error;
28+
use function curl_exec;
29+
use function curl_getinfo;
2830
use function curl_init;
2931
use function curl_setopt;
3032
use function http_build_query;
@@ -155,15 +157,14 @@ public function sendRequest(
155157
curl_setopt($curlHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
156158
curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, 1);// Issues moved to another repo have redirects
157159
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
158-
$response = curl_exec($curlHandle);// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFallbackGlobalName
160+
$response = curl_exec($curlHandle);
159161
if ($response === false) {
160162
Log::error('Curl error: "' . curl_error($curlHandle) . '" for: ' . $url);
161163

162164
return ['', 0];
163165
}
164166

165-
$status = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFallbackGlobalName
166-
// phpcs ignored patterns for mock testing reasons
167+
$status = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
167168
Log::debug('Response-code: ' . $status . ' for: ' . $url);
168169

169170
$decodedResponse = json_decode($response, true);

src/Forwarding/Sentry.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use function curl_errno;
1212
use function curl_exec;
13+
use function curl_getinfo;
1314
use function curl_init;
1415
use function curl_setopt;
1516
use function curl_strerror;
@@ -22,6 +23,7 @@
2223
use function json_encode;
2324
use function time;
2425

26+
use const CURLINFO_HTTP_CODE;
2527
use const CURLOPT_CAINFO;
2628
use const CURLOPT_CAPATH;
2729
use const CURLOPT_HTTPHEADER;
@@ -154,6 +156,9 @@ public static function sendFeedback(string $eventId, string $comments, string $u
154156
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
155157

156158
$output = curl_exec($ch);
159+
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
160+
Log::debug('Response-code: ' . $status);
161+
157162
if (! is_string($output)) {
158163
$error = 'Creating the report feedback failed: ' . json_encode($output);
159164
Log::error($error);

0 commit comments

Comments
 (0)