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.8.7 lib/scout/http.rb
scout-5.8.7.pre lib/scout/http.rb
scout-5.8.6 lib/scout/http.rb
scout-5.8.5 lib/scout/http.rb
scout-5.8.5.pre lib/scout/http.rb
scout-5.8.4 lib/scout/http.rb
scout-5.8.3 lib/scout/http.rb
scout-5.8.1 lib/scout/http.rb
scout-5.8.0 lib/scout/http.rb
scout-5.8.0.pre lib/scout/http.rb
scout-5.7.5 lib/scout/http.rb
scout-5.7.4 lib/scout/http.rb
scout-5.7.3.pre.2 lib/scout/http.rb
scout-5.7.3.pre lib/scout/http.rb
scout-5.7.2 lib/scout/http.rb
scout-5.7.2.pre.2 lib/scout/http.rb