Sha256: c6229bdb20b478eca54f429e47a52f3d37782d8585a66f31e95ac1e500be385f

Contents?: true

Size: 888 Bytes

Versions: 36

Compression:

Stored size: 888 Bytes

Contents

require "net/https"
require "uri"

module Scout
  module HTTP
    CA_FILE     = File.join( File.dirname(__FILE__), *%w[.. .. data cacert.pem] )
    VERIFY_MODE = OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT

    # 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
    def build_http(uri)
      proxy_uri = URI.parse(uri.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(uri.host, uri.port)

      if uri.is_a?(URI::HTTPS)
        http.use_ssl = true
        http.ca_file = CA_FILE
        http.verify_mode = VERIFY_MODE        
      end
      http
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
scout-5.9.13 lib/scout/http.rb
scout-5.9.12 lib/scout/http.rb
scout-5.9.11 lib/scout/http.rb
scout-5.9.10.pre lib/scout/http.rb
scout-5.9.8 lib/scout/http.rb
scout-5.9.7.2.pre lib/scout/http.rb
scout-5.9.8.pre lib/scout/http.rb
scout-5.9.7.1 lib/scout/http.rb
scout-5.9.7.pre lib/scout/http.rb
scout-5.9.5 lib/scout/http.rb
scout-5.9.4 lib/scout/http.rb
scout-5.9.4.pre lib/scout/http.rb
scout-5.9.3 lib/scout/http.rb
scout-5.9.2 lib/scout/http.rb
scout-5.9.1 lib/scout/http.rb
scout-5.9.1.pre lib/scout/http.rb
scout-5.9.0 lib/scout/http.rb
scout-5.9.0.pre lib/scout/http.rb
scout-5.8.9 lib/scout/http.rb
scout-5.8.8 lib/scout/http.rb