utils/curl.rb: accept 1xx HTTP status codes
RFC 2616 states: A client MUST be prepared to accept one or more 1xx status responses prior to a regular response, even if the client does not expect a 100 (Continue) status message. Unexpected 1xx status responses MAY be ignored by a user agent. In the rare cases that we encounter a formula URL with a server that provides a preliminary 1xx status code, it seems that (at least during audit) we are failing on encountering this status code, even though retrieving the file will succeed without issues.
This commit is contained in:
parent
d40a4173d4
commit
78a0105fe2
@ -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 (100..299).include?(details[:status].to_i)
|
||||
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 (100..299).include?(details[:status].to_i)
|
||||
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 !(100..299).include?(details[:status].to_i) ||
|
||||
!(100..299).include?(secure_details[:status].to_i)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user