class CQ::HttpClient
Constants
- DEFAULT_OPTIONS
Attributes
options[R]
Public Class Methods
new(options)
click to toggle source
# File lib/cq/http_client.rb, line 15 def initialize(options) @options = DEFAULT_OPTIONS.merge(options) end
Public Instance Methods
basic_auth_http_conn()
click to toggle source
# File lib/cq/http_client.rb, line 27 def basic_auth_http_conn http_conn(uri) end
http_conn(uri)
click to toggle source
# File lib/cq/http_client.rb, line 31 def http_conn(uri) # if @options[:proxy_address] # http_class = Net::HTTP::Proxy(@options[:proxy_address], @options[:proxy_port] ? @options[:proxy_port] : 80) # else # http_class = Net::HTTP # end http_conn = Net::HTTP.new(uri.host, uri.port) http_conn end
make_request(http_method, path, body='', headers={})
click to toggle source
# File lib/cq/http_client.rb, line 19 def make_request(http_method, path, body='', headers={}) request = Net::HTTP.const_get(http_method.to_s.capitalize).new(path, headers) request.body = body unless body.nil? request.basic_auth(@options[:username], @options[:password]) response = basic_auth_http_conn.request(request) response end
uri()
click to toggle source
# File lib/cq/http_client.rb, line 41 def uri uri = URI.parse(@options[:site]) end