From ed9f775b778bad961a9e2fb178fce3a7af201e75 Mon Sep 17 00:00:00 2001 From: David Broder-Rodgers Date: Sat, 10 Dec 2016 14:20:47 +0000 Subject: Added support for returning HTTP status codes and for git and svn URLs --- Library/Homebrew/dev-cmd/audit.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index db7973eb3..839d1c429 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1490,10 +1490,20 @@ class ResourceAuditor return unless @online urls.each do |url| - begin - nostdout { curl "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", url } - rescue ErrorDuringExecution - problem "The mirror #{url} is not reachable (curl exit code #{$?.exitstatus})" + if url.start_with? "http", "ftp" + status_code, _, _ = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", \ + "--write-out", "%{http_code}", url + unless status_code.start_with? "20" + problem "The mirror #{url} is not reachable (HTTP status code #{status_code})" + end + elsif url.start_with? "git" + unless Utils.git_remote_exists url + problem "The mirror #{url} is not a valid git URL" + end + elsif url.start_with? "svn" + unless Utils.svn_remote_exists url + problem "The mirror #{url} is not a valid svn URL" + end end check_insecure_mirror(url) if url.start_with? "http:" end -- cgit v1.2.3