class Io::Flow::Reference::V0::HttpClient::DefaultHttpHandlerInstance
Attributes
client[R]
Public Class Methods
new(base_uri)
click to toggle source
# File lib/flow_reference_v0_client.rb, line 949 def initialize(base_uri) @base_uri = Preconditions.assert_class('base_uri', base_uri, URI) @client = Net::HTTP.new(@base_uri.host, @base_uri.port) if @base_uri.scheme == "https" configure_ssl end end
Public Instance Methods
configure_ssl()
click to toggle source
Called to configure SSL if the base uri requires it
# File lib/flow_reference_v0_client.rb, line 978 def configure_ssl @client.use_ssl = true @client.verify_mode = OpenSSL::SSL::VERIFY_PEER @client.cert_store = OpenSSL::X509::Store.new @client.cert_store.set_default_paths end
execute(request)
click to toggle source
# File lib/flow_reference_v0_client.rb, line 957 def execute(request) response = begin @client.request(request) rescue SocketError => e raise StandardError.new("Error accessing uri[#{full_uri(request.path)}]: #{e}") end case response when Net::HTTPSuccess response.body else body = response.body rescue nil raise HttpClient::ServerError.new(response.code.to_i, response.message, :body => body, :uri => full_uri(request.path).to_s) end end
full_uri(path)
click to toggle source
# File lib/flow_reference_v0_client.rb, line 973 def full_uri(path) path.start_with?(@base_uri.to_s) ? path : File.join(@base_uri.to_s, path) end