Class: Net::Hippie::Connection
- Inherits:
-
Object
- Object
- Net::Hippie::Connection
- Defined in:
- lib/net/hippie/connection.rb
Overview
A connection to a specific host
Instance Method Summary collapse
- #build_url_for(path) ⇒ Object
-
#initialize(scheme, host, port, options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #run(request) ⇒ Object
Constructor Details
#initialize(scheme, host, port, options = {}) ⇒ Connection
Returns a new instance of Connection.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/net/hippie/connection.rb', line 7 def initialize(scheme, host, port, = {}) http = Net::HTTP.new(host, port) http.read_timeout = .fetch(:read_timeout, 10) http.open_timeout = .fetch(:open_timeout, 10) http.use_ssl = scheme == 'https' http.verify_mode = .fetch(:verify_mode, Net::Hippie.verify_mode) http.set_debug_output(.fetch(:logger, Net::Hippie.logger)) apply_client_tls_to(http, ) @http = http end |
Instance Method Details
#build_url_for(path) ⇒ Object
22 23 24 25 26 |
# File 'lib/net/hippie/connection.rb', line 22 def build_url_for(path) return path if path.start_with?('http') "#{@http.use_ssl? ? 'https' : 'http'}://#{@http.address}#{path}" end |
#run(request) ⇒ Object
18 19 20 |
# File 'lib/net/hippie/connection.rb', line 18 def run(request) @http.request(request) end |