diff --git a/dockerfiles/depwatcher/src/depwatcher/httpd.cr b/dockerfiles/depwatcher/src/depwatcher/httpd.cr index 989557f03..289779db8 100644 --- a/dockerfiles/depwatcher/src/depwatcher/httpd.cr +++ b/dockerfiles/depwatcher/src/depwatcher/httpd.cr @@ -25,9 +25,33 @@ module Depwatcher end def in(ref : String) : Release - sha_response = HTTP::Client.get("https://archive.apache.org/dist/httpd/httpd-#{ref}.tar.bz2.sha256").body - sha256 = sha_response.split(" ")[0] - Release.new(ref, "https://dlcdn.apache.org/httpd/httpd-#{ref}.tar.bz2", sha256) + sha_response = nil + max_retries = 3 + retries = 0 + + while retries < max_retries + begin + sha_response = HTTP::Client.get("https://archive.apache.org/dist/httpd/httpd-#{ref}.tar.bz2.sha256") + if sha_response.status_code != 200 + puts "Attempt #{retries + 1}: Received status #{sha_response.status_code}, retrying..." + retries += 1 + sleep(5) + else + puts "Success: Received status 200" + break + end + rescue ex + puts "Failed with error: #{ex.message}, retrying..." + end + end + + unless sha_response.nil? + sha256 = sha_response.body.split(" ")[0] + puts sha256 + Release.new(ref, "https://dlcdn.apache.org/httpd/httpd-#{ref}.tar.bz2", sha256) + else + raise "Could not retreive the page after #{max_retries} attempts" + end end end end