aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-08-04 15:37:35 +0200
committerMarkus Reiter2017-08-04 15:39:32 +0200
commit12d4226bfc2dd4c1c06d8c1e8ba7b7e84982c290 (patch)
tree3c2f0ac6f57e406db7e3ae425935dd18c7e71681 /Library
parent1cae6dd6777aa6657c0df500a32ef68cefb2b746 (diff)
downloadbrew-12d4226bfc2dd4c1c06d8c1e8ba7b7e84982c290.tar.bz2
Remove `_checkurl`.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli.rb1
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_checkurl.rb19
-rw-r--r--Library/Homebrew/cask/lib/hbc/fetcher.rb24
-rw-r--r--Library/Homebrew/cask/lib/hbc/url_checker.rb78
-rw-r--r--Library/Homebrew/test/cask/url_checker_spec.rb42
6 files changed, 0 insertions, 166 deletions
diff --git a/Library/Homebrew/cask/lib/hbc.rb b/Library/Homebrew/cask/lib/hbc.rb
index 5b94a1b55..780acedf5 100644
--- a/Library/Homebrew/cask/lib/hbc.rb
+++ b/Library/Homebrew/cask/lib/hbc.rb
@@ -16,7 +16,6 @@ require "hbc/container"
require "hbc/download"
require "hbc/download_strategy"
require "hbc/exceptions"
-require "hbc/fetcher"
require "hbc/installer"
require "hbc/locations"
require "hbc/macos"
@@ -28,7 +27,6 @@ require "hbc/system_command"
require "hbc/topological_hash"
require "hbc/underscore_supporting_uri"
require "hbc/url"
-require "hbc/url_checker"
require "hbc/utils"
require "hbc/verify"
require "hbc/version"
diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb
index 0108c1621..d260be4e3 100644
--- a/Library/Homebrew/cask/lib/hbc/cli.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli.rb
@@ -27,7 +27,6 @@ require "hbc/cli/zap"
require "hbc/cli/abstract_internal_command"
require "hbc/cli/internal_audit_modified_casks"
require "hbc/cli/internal_appcast_checkpoint"
-require "hbc/cli/internal_checkurl"
require "hbc/cli/internal_dump"
require "hbc/cli/internal_help"
require "hbc/cli/internal_stanza"
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_checkurl.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_checkurl.rb
deleted file mode 100644
index a8c3d5c8f..000000000
--- a/Library/Homebrew/cask/lib/hbc/cli/internal_checkurl.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-module Hbc
- class CLI
- class InternalCheckurl < AbstractInternalCommand
- def run
- casks_to_check = args.empty? ? Hbc.all : args.map(&CaskLoader.public_method(:load))
- casks_to_check.each do |cask|
- odebug "Checking URL for Cask #{cask}"
- checker = UrlChecker.new(cask)
- checker.run
- puts checker.summary
- end
- end
-
- def self.help
- "checks for bad Cask URLs"
- end
- end
- end
-end
diff --git a/Library/Homebrew/cask/lib/hbc/fetcher.rb b/Library/Homebrew/cask/lib/hbc/fetcher.rb
deleted file mode 100644
index fb2b743fa..000000000
--- a/Library/Homebrew/cask/lib/hbc/fetcher.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require "open3"
-
-module Hbc
- class Fetcher
- TIMEOUT = 10
-
- def self.head(url)
- if url.to_s =~ /googlecode/
- googlecode_fake_head(url)
- else
- SystemCommand.run("/usr/bin/curl",
- args: ["--max-time", TIMEOUT, "--silent", "--location", "--head", url]).stdout
- end
- end
-
- # google code does not properly respond to HTTP HEAD requests, like a jerk
- # this fakes a HEAD by doing a GET, taking the first 20 lines, then running away
- def self.googlecode_fake_head(url)
- command = "curl --max-time #{TIMEOUT} --verbose --location '#{url}' | head -n 20 > /dev/null"
- stderr = Open3.capture3(command)[1]
- stderr.split("\n").grep(/^< /).map { |line| line.sub(/^< /, "") }.join("\n")
- end
- end
-end
diff --git a/Library/Homebrew/cask/lib/hbc/url_checker.rb b/Library/Homebrew/cask/lib/hbc/url_checker.rb
deleted file mode 100644
index 7076b13c5..000000000
--- a/Library/Homebrew/cask/lib/hbc/url_checker.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-require "hbc/checkable"
-require "hbc/fetcher"
-
-module Hbc
- class UrlChecker
- attr_accessor :cask, :response_status, :headers
-
- include Checkable
-
- def initialize(cask, fetcher = Fetcher)
- @cask = cask
- @fetcher = fetcher
- @headers = {}
- end
-
- def summary_header
- "url check result for #{cask}"
- end
-
- def run
- _get_data_from_request
- return if errors?
- _check_response_status
- end
-
- HTTP_RESPONSES = [
- "HTTP/1.0 200 OK",
- "HTTP/1.1 200 OK",
- "HTTP/1.1 302 Found",
- ].freeze
-
- OK_RESPONSES = {
- "http" => HTTP_RESPONSES,
- "https" => HTTP_RESPONSES,
- "ftp" => ["OK"],
- }.freeze
-
- def _check_response_status
- ok = OK_RESPONSES[cask.url.scheme]
- return if ok.include?(@response_status)
- add_error "unexpected http response, expecting #{ok.map(&:to_s).join(" or ")}, got #{@response_status}"
- end
-
- def _get_data_from_request
- response = @fetcher.head(cask.url)
-
- if response.empty?
- add_error "timeout while requesting #{cask.url}"
- return
- end
-
- response_lines = response.split("\n").map(&:chomp)
-
- case cask.url.scheme
- when "http", "https" then
- @response_status = response_lines.grep(/^HTTP/).last
- if @response_status.respond_to?(:strip)
- @response_status.strip!
- unless response_lines.index(@response_status).nil?
- http_headers = response_lines[(response_lines.index(@response_status) + 1)..-1]
- http_headers.each do |line|
- header_name, header_value = line.split(": ")
- @headers[header_name] = header_value
- end
- end
- end
- when "ftp" then
- @response_status = "OK"
- response_lines.each do |line|
- header_name, header_value = line.split(": ")
- @headers[header_name] = header_value
- end
- else
- add_error "unknown scheme for #{cask.url}"
- end
- end
- end
-end
diff --git a/Library/Homebrew/test/cask/url_checker_spec.rb b/Library/Homebrew/test/cask/url_checker_spec.rb
deleted file mode 100644
index c505d2cb4..000000000
--- a/Library/Homebrew/test/cask/url_checker_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-describe Hbc::UrlChecker, :cask do
- describe "request processing" do
- let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
- let(:checker) { Hbc::UrlChecker.new(cask) }
-
- before(:each) do
- allow(Hbc::Fetcher).to receive(:head).and_return(response)
- checker.run
- end
-
- context "with an empty response" do
- let(:response) { "" }
-
- it "adds an error" do
- expect(checker.errors).to include("timeout while requesting #{cask.url}")
- end
- end
-
- context "with a valid http response" do
- let(:response) {
- <<-EOS.undent
- HTTP/1.1 200 OK
- Content-Type: application/x-apple-diskimage
- ETag: "b4208f3e84967be4b078ecaa03fba941"
- Content-Length: 23726161
- Last-Modified: Sun, 12 Aug 2012 21:17:21 GMT
- EOS
- }
-
- it "properly populates the response code and headers" do
- expect(checker.errors).to be_empty
- expect(checker.response_status).to eq("HTTP/1.1 200 OK")
- expect(checker.headers).to eq(
- "Content-Type" => "application/x-apple-diskimage",
- "ETag" => '"b4208f3e84967be4b078ecaa03fba941"',
- "Content-Length" => "23726161",
- "Last-Modified" => "Sun, 12 Aug 2012 21:17:21 GMT",
- )
- end
- end
- end
-end