Class: BerkeleyLibrary::Util::HeadCheck

Inherits:
OkComputer::HttpCheck
  • Object
show all
Defined in:
lib/berkeley_library/util/uris/head_check.rb

Instance Method Summary collapse

Instance Method Details

#perform_requestObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/berkeley_library/util/uris/head_check.rb', line 9

def perform_request
  headers = {}
  if basic_auth_options.any?
    user, password = basic_auth_options
    headers['Authorization'] = "Basic #{Base64.strict_encode64("#{user}:#{password}")}"
  end

  options = { headers: headers, log: false }
  options[:timeout] = request_timeout.to_i if request_timeout

  URIs.head_response(url, **options)
rescue StandardError => e
  raise OkComputer::HttpCheck::ConnectionFailed, e
end