Skip to content

Commit

Permalink
Log Helper::getRemoteFileContents() errors
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-help-desk committed Jul 22, 2024
1 parent 029e5c8 commit efca2ac
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions app/Misc/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,8 @@ public static function getRemoteFileContents($url)

// 307 - Temporary Redirect.
if (!preg_match("/(200|301|302|307)/", $headers[0])) {
return false;
throw new \Exception('HTTP Status Code: '.$headers[0], 1);
//return false;
}

$ch = curl_init();
Expand All @@ -1671,14 +1672,19 @@ public static function getRemoteFileContents($url)
curl_setopt($ch, CURLOPT_TIMEOUT, 180);
$contents = curl_exec($ch);

if (curl_errno($ch)) {
throw new \Exception(curl_errno($ch).' '.curl_error($ch), 1);
}
$curl_errno = curl_errno($ch);

curl_close($ch);
if ($curl_errno) {
throw new \Exception('Curl Error Number: '.$curl_errno, 1);
}

if (!$contents) {
return false;
if ($contents == '') {
$https_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
throw new \Exception('Empty Response. Curl Error Number: '.$curl_errno.'. Response Status Code: '.$https_status, 1);
//return false;
} else {
curl_close($ch);
}

return $contents;
Expand Down

0 comments on commit efca2ac

Please sign in to comment.