Module: DeadFinder::HttpClient
- Defined in:
- lib/deadfinder/http_client.rb
Overview
HTTP client module
Class Method Summary collapse
Class Method Details
.create(uri, options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/deadfinder/http_client.rb', line 9 def self.create(uri, ) begin proxy_uri = URI.parse(['proxy']) if ['proxy'] && !['proxy'].empty? rescue URI::InvalidURIError => e DeadFinder::Logger.error "Invalid proxy URI: #{['proxy']} - #{e.}" proxy_uri = nil # or handle the error as appropriate end http = if proxy_uri Net::HTTP.new(uri.host, uri.port, proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password) else Net::HTTP.new(uri.host, uri.port) end http.use_ssl = (uri.scheme == 'https') http.read_timeout = ['timeout'].to_i if ['timeout'] http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl? if ['proxy_auth'] && proxy_uri proxy_user, proxy_pass = ['proxy_auth'].split(':', 2) http.proxy_user = proxy_user http.proxy_pass = proxy_pass end http end |