class Keen::HTTP::Sync
Public Class Methods
new(base_url, proxy_url=nil, read_timeout=nil, open_timeout=nil)
click to toggle source
# File lib/keen/http.rb, line 4 def initialize(base_url, proxy_url=nil, read_timeout=nil, open_timeout=nil) require 'uri' require 'net/http' uri = URI.parse(base_url) arguments = [uri.host, uri.port] arguments+= proxy_arguments_for(proxy_url) if proxy_url @http = Net::HTTP.new(*arguments) @http.open_timeout = open_timeout if open_timeout @http.read_timeout = read_timeout if read_timeout if uri.scheme == "https" require 'net/https' @http.use_ssl = true; @http.verify_mode = OpenSSL::SSL::VERIFY_PEER @http.verify_depth = 5 @http.ca_file = File.expand_path("../../../config/cacert.pem", __FILE__) end end
Public Instance Methods
delete(options)
click to toggle source
# File lib/keen/http.rb, line 48 def delete(options) path, headers = options.values_at( :path, :headers) @http.delete(path, headers) end
get(options)
click to toggle source
# File lib/keen/http.rb, line 42 def get(options) path, headers = options.values_at( :path, :headers) @http.get(path, headers) end
post(options)
click to toggle source
# File lib/keen/http.rb, line 30 def post(options) path, headers, body = options.values_at( :path, :headers, :body) @http.post(path, body, headers) end
proxy_arguments_for(uri)
click to toggle source
# File lib/keen/http.rb, line 25 def proxy_arguments_for(uri) proxy_uri = URI.parse(uri) [proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password] end
put(options)
click to toggle source
# File lib/keen/http.rb, line 36 def put(options) path, headers, body = options.values_at( :path, :headers, :body) @http.put(path, body, headers) end