Module: RequestVia::HTTPClient

Extended by:
HTTPClient
Included in:
HTTPClient
Defined in:
lib/request_via/http_client.rb

Constant Summary collapse

Build =
Freeze.(-> (host, port) {
  Net::HTTP.new(host, port)
})

Instance Method Summary collapse

Instance Method Details

#call(uri, port = nil, open_timeout = nil, read_timeout = nil, net_http = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/request_via/http_client.rb', line 11

def call(uri, port = nil, open_timeout = nil, read_timeout = nil, net_http = nil)
  net_http = build!(uri, port, net_http)

  net_http.open_timeout = Integer(open_timeout) unless open_timeout.nil?
  net_http.read_timeout = Integer(read_timeout) unless read_timeout.nil?

  return net_http unless uri.is_a?(URI::HTTPS)

  set_https!(net_http)
end