Class: Keen::HTTP::Sync
- Inherits:
-
Object
- Object
- Keen::HTTP::Sync
- Defined in:
- lib/keen/http.rb
Instance Method Summary collapse
- #delete(options) ⇒ Object
- #get(options) ⇒ Object
-
#initialize(base_url, proxy_url = nil, read_timeout = nil) ⇒ Sync
constructor
A new instance of Sync.
- #post(options) ⇒ Object
- #proxy_arguments_for(uri) ⇒ Object
Constructor Details
#initialize(base_url, proxy_url = nil, read_timeout = nil) ⇒ Sync
Returns a new instance of Sync.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/keen/http.rb', line 4 def initialize(base_url, proxy_url=nil, read_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.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.("../../../config/cacert.pem", __FILE__) end end |
Instance Method Details
#delete(options) ⇒ Object
41 42 43 44 45 |
# File 'lib/keen/http.rb', line 41 def delete() path, headers = .values_at( :path, :headers) @http.delete(path, headers) end |
#get(options) ⇒ Object
35 36 37 38 39 |
# File 'lib/keen/http.rb', line 35 def get() path, headers = .values_at( :path, :headers) @http.get(path, headers) end |
#post(options) ⇒ Object
29 30 31 32 33 |
# File 'lib/keen/http.rb', line 29 def post() path, headers, body = .values_at( :path, :headers, :body) @http.post(path, body, headers) end |
#proxy_arguments_for(uri) ⇒ Object
24 25 26 27 |
# File 'lib/keen/http.rb', line 24 def proxy_arguments_for(uri) proxy_uri = URI.parse(uri) [proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password] end |