Class: Captive::HttpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/captive/http_client.rb

Instance Method Summary collapse

Instance Method Details

#get(url, headers = {}) ⇒ Object



17
18
19
# File 'lib/captive/http_client.rb', line 17

def get(url, headers = {})
  request(url) { |http, uri| http.get(uri.request_uri, { "Accept" => "application/json" }.merge(headers)) }
end

#post(url, params) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/captive/http_client.rb', line 9

def post(url, params)
  request(url) do |http, uri|
    http.post(uri.request_uri, URI.encode_www_form(params),
              "Accept"       => "application/json",
              "Content-Type" => "application/x-www-form-urlencoded")
  end
end