Class: EncodingDotCom::HttpAdapters::NetHttpAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/encoding_dot_com/http_adapters/net_http_adapter.rb

Overview

Wraps the Net/HTTP library for use with the Queue.

Instance Method Summary collapse

Constructor Details

#initializeNetHttpAdapter

Returns a new instance of NetHttpAdapter.



6
7
8
# File 'lib/encoding_dot_com/http_adapters/net_http_adapter.rb', line 6

def initialize
  require 'net/http'
end

Instance Method Details

#post(url, parameters = {}) ⇒ Object

Makes a POST request. Raises an AvailabilityError if the request times out or has other problems.



12
13
14
15
16
17
18
# File 'lib/encoding_dot_com/http_adapters/net_http_adapter.rb', line 12

def post(url, parameters={})
  Net::HTTP.post_form(URI.parse(url), parameters)
rescue => e
  raise AvailabilityError.new(e.message)
rescue Timeout::Error => e
  raise AvailabilityError.new(e.message)          
end