Class: EncodingDotCom::HttpAdapters::NetHttpAdapter
- Inherits:
-
Object
- Object
- EncodingDotCom::HttpAdapters::NetHttpAdapter
- 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
-
#initialize ⇒ NetHttpAdapter
constructor
A new instance of NetHttpAdapter.
-
#post(url, parameters = {}) ⇒ Object
Makes a POST request.
Constructor Details
#initialize ⇒ NetHttpAdapter
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.) rescue Timeout::Error => e raise AvailabilityError.new(e.) end |