Class: Animoto::HTTPEngines::NetHTTPAdapter

Inherits:
Base
  • Object
show all
Defined in:
lib/animoto/http_engines/net_http_adapter.rb

Constant Summary collapse

HTTP_METHOD_MAP =

A map of HTTP verb symbols to the Net::HTTP classes that handle them.

{
  :head   => Net::HTTP::Head,
  :get    => Net::HTTP::Get,
  :post   => Net::HTTP::Post,
  :put    => Net::HTTP::Put,
  :delete => Net::HTTP::Delete
}

Instance Method Summary collapse

Instance Method Details

#request(method, url, body = nil, headers = {}, options = {}) ⇒ String

Returns:

  • (String)


18
19
20
21
22
23
24
# File 'lib/animoto/http_engines/net_http_adapter.rb', line 18

def request method, url, body = nil, headers = {}, options = {}
  uri = URI.parse(url)
  http = build_http uri, options
  req = build_request method, uri, body, headers, options        
  response = http.request req
  [response.code.to_i, response.body]
end