Merge pull request #6463 from alebcay/1xx-status-codes
utils/curl.rb: accept 1xx HTTP status codes
This commit is contained in:
commit
aacdf4f2bd
@ -94,7 +94,7 @@ def curl_check_http_content(url, user_agents: [:default], check_content: false,
|
||||
user_agents.each do |ua|
|
||||
details = curl_http_content_headers_and_checksum(url, hash_needed: hash_needed, user_agent: ua)
|
||||
user_agent = ua
|
||||
break if details[:status].to_s.start_with?("2")
|
||||
break if http_status_ok?(details[:status])
|
||||
end
|
||||
|
||||
unless details[:status]
|
||||
@ -104,7 +104,7 @@ def curl_check_http_content(url, user_agents: [:default], check_content: false,
|
||||
return "The URL #{url} is not reachable"
|
||||
end
|
||||
|
||||
unless details[:status].start_with? "2"
|
||||
unless http_status_ok?(details[:status])
|
||||
return "The URL #{url} is not reachable (HTTP status code #{details[:status]})"
|
||||
end
|
||||
|
||||
@ -119,8 +119,8 @@ def curl_check_http_content(url, user_agents: [:default], check_content: false,
|
||||
secure_details =
|
||||
curl_http_content_headers_and_checksum(secure_url, hash_needed: true, user_agent: user_agent)
|
||||
|
||||
if !details[:status].to_s.start_with?("2") ||
|
||||
!secure_details[:status].to_s.start_with?("2")
|
||||
if !http_status_ok?(details[:status]) ||
|
||||
!http_status_ok?(secure_details[:status])
|
||||
return
|
||||
end
|
||||
|
||||
@ -192,3 +192,7 @@ def curl_http_content_headers_and_checksum(url, hash_needed: false, user_agent:
|
||||
file: output,
|
||||
}
|
||||
end
|
||||
|
||||
def http_status_ok?(status)
|
||||
(100..299).cover?(status.to_i)
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user