lib/scout/server_base.rb in scout-5.5.1 vs lib/scout/server_base.rb in scout-5.5.2

- old
+ new

@@ -51,10 +51,16 @@ end def request(url, response_handler, error, &connector) response = nil Timeout.timeout(5 * 60, APITimeoutError) do - http = Net::HTTP.new(url.host, url.port) + # take care of http/https proxy, if specified in command line options + # Given a blank string, the proxy_uri URI instance's host/port/user/pass will be nil + # Net::HTTP::Proxy returns a regular Net::HTTP class if the first argument (host) is nil + info "using http_proxy=#{@http_proxy}, https_proxy=#{@https_proxy}" if @http_proxy != '' || @https_proxy != '' + proxy_uri = URI.parse(url.is_a?(URI::HTTPS) ? @https_proxy : @http_proxy) + http=Net::HTTP::Proxy(proxy_uri.host,proxy_uri.port,proxy_uri.user,proxy_uri.port).new(url.host, url.port) + if url.is_a? URI::HTTPS http.use_ssl = true http.ca_file = File.join(File.dirname(__FILE__), *%w[.. .. data cacert.pem]) http.verify_mode = OpenSSL::SSL::VERIFY_PEER |