aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd
diff options
context:
space:
mode:
authorMike McQuaid2017-01-26 16:19:38 +0000
committerMike McQuaid2017-01-26 16:19:38 +0000
commit34e03532a02318b5e9b43fba7e73890c6e403062 (patch)
tree81d976986a96db82757446dd39171a7037ae42b9 /Library/Homebrew/dev-cmd
parent1f97e3186a117541f127f6e52ce77238a2791147 (diff)
downloadbrew-34e03532a02318b5e9b43fba7e73890c6e403062.tar.bz2
audit: improve homepage audit reliability.
Try first with an (exact, actual) browser user agent from Safari and then try again with the default Homebrew `curl` user agent.
Diffstat (limited to 'Library/Homebrew/dev-cmd')
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb17
1 files changed, 8 insertions, 9 deletions
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 5b0102130..b5dc4ecb1 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -169,7 +169,7 @@ class FormulaAuditor
@specs = %w[stable devel head].map { |s| formula.send(s) }.compact
end
- def url_status_code(url, range: false, user_agent: :default)
+ def url_status_code(url, range: false)
# The system Curl is too old and unreliable with HTTPS homepages on
# Yosemite and below.
return "200" unless DevelopmentTools.curl_handles_most_https_homepages?
@@ -182,14 +182,13 @@ class FormulaAuditor
extra_args << "--range" << "0-0" if range
extra_args << url
- args = curl_args(
- extra_args: extra_args,
- show_output: true,
- user_agent: user_agent
- )
- retries = 3
status_code = nil
- retries.times do
+ [:browser, :default].each do |user_agent|
+ args = curl_args(
+ extra_args: extra_args,
+ show_output: true,
+ user_agent: user_agent
+ )
status_code = Open3.popen3(*args) { |_, stdout, _, _| stdout.read }
break if status_code.start_with? "20"
end
@@ -609,7 +608,7 @@ class FormulaAuditor
return unless @online
- status_code = url_status_code(homepage, user_agent: :browser)
+ status_code = url_status_code(homepage)
return if status_code.start_with? "20"
problem "The homepage #{homepage} is not reachable (HTTP status code #{status_code})"
end