class NineOneOne::Http
Constants
- NET_HTTP_EXCEPTIONS
rubocop:disable Style/MutableConstant
Attributes
net_http[R]
Public Class Methods
new(base_host, scheme = 'https')
click to toggle source
# File lib/nine_one_one/http.rb, line 37 def initialize(base_host, scheme = 'https') port, use_ssl = scheme == 'https' ? [443, true] : [80, false] @net_http = Net::HTTP.new(base_host, port) @net_http.use_ssl = use_ssl end
Public Instance Methods
post(path, body, headers)
click to toggle source
# File lib/nine_one_one/http.rb, line 45 def post(path, body, headers) post!(path, body, headers) rescue *NET_HTTP_EXCEPTIONS => err err_class = if defined?(OpenSSL) && err.is_a?(OpenSSL::SSL::SSLError) SSLError else ConnectionFailedError end raise err_class, err rescue Timeout::Error, Errno::ETIMEDOUT => err raise TimeoutError, err end
Private Instance Methods
post!(path, body, headers)
click to toggle source
# File lib/nine_one_one/http.rb, line 61 def post!(path, body, headers) request = Net::HTTP::Post.new(path, headers) request.body = body net_http.request(request) end