[PHP-WEBMASTER] [web-downloads] main: Check HTTP status code in FetchArtifact

Author: Shivam Mathur (shivammathur)
Date: 2026-04-02T06:55:38+05:30

Commit: Check HTTP status code in FetchArtifact · php/web-downloads@7b7ee8e · GitHub
Raw diff: https://github.com/php/web-downloads/commit/7b7ee8e4655e5ea5e631d3a995aeb881ae6fc1e2.diff

Check HTTP status code in FetchArtifact

Changed paths:
  M src/Actions/FetchArtifact.php

Diff:

diff --git a/src/Actions/FetchArtifact.php b/src/Actions/FetchArtifact.php
index 03b70fd..d2d1a60 100644
--- a/src/Actions/FetchArtifact.php
+++ b/src/Actions/FetchArtifact.php
@@ -25,11 +25,16 @@ public function handle($url, $filepath, #[\SensitiveParameter] $token = null): v
         }
         $result = curl_exec($ch);
         $error = curl_error($ch);
+ $httpCode = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
         curl_close($ch);
         fclose($fp);
         if ($result === false) {
             unlink($filepath);
             throw new \RuntimeException('cURL error: ' . $error);
         }
+ if ($httpCode >= 400) {
+ unlink($filepath);
+ throw new \RuntimeException('HTTP error: ' . $httpCode);
+ }
     }
}
\ No newline at end of file