Rescue ErrorDuringExecution
instead of changing curl_headers
return type.
This commit is contained in:
parent
16f3a05e45
commit
e493d0cb04
@ -182,6 +182,7 @@ module Homebrew
|
|||||||
headers = []
|
headers = []
|
||||||
|
|
||||||
[:default, :browser].each do |user_agent|
|
[:default, :browser].each do |user_agent|
|
||||||
|
begin
|
||||||
parsed_output = curl_headers(
|
parsed_output = curl_headers(
|
||||||
url,
|
url,
|
||||||
wanted_headers: ["location", "content-disposition"],
|
wanted_headers: ["location", "content-disposition"],
|
||||||
@ -189,7 +190,9 @@ module Homebrew
|
|||||||
user_agent: user_agent,
|
user_agent: user_agent,
|
||||||
**DEFAULT_CURL_OPTIONS,
|
**DEFAULT_CURL_OPTIONS,
|
||||||
)
|
)
|
||||||
next if parsed_output.blank?
|
rescue ErrorDuringExecution
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
parsed_output[:responses].each { |response| headers << response[:headers] }
|
parsed_output[:responses].each { |response| headers << response[:headers] }
|
||||||
break if headers.present?
|
break if headers.present?
|
||||||
|
@ -213,8 +213,7 @@ module Utils
|
|||||||
)
|
)
|
||||||
|
|
||||||
# 22 means a non-successful HTTP status code, not a `curl` error, so we still got some headers.
|
# 22 means a non-successful HTTP status code, not a `curl` error, so we still got some headers.
|
||||||
next if !result.success? && result.exit_status != 22
|
if result.success? || result.exit_status == 22
|
||||||
|
|
||||||
parsed_output = parse_curl_output(result.stdout)
|
parsed_output = parse_curl_output(result.stdout)
|
||||||
|
|
||||||
# If we didn't get any wanted header yet, retry using `GET`.
|
# If we didn't get any wanted header yet, retry using `GET`.
|
||||||
@ -224,7 +223,8 @@ module Utils
|
|||||||
return parsed_output if result.success?
|
return parsed_output if result.success?
|
||||||
end
|
end
|
||||||
|
|
||||||
nil
|
result.assert_success!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if a URL is protected by CloudFlare (e.g. badlion.net and jaxx.io).
|
# Check if a URL is protected by CloudFlare (e.g. badlion.net and jaxx.io).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user