Class: ReeHttp::BuildRequestExecutor

Inherits:
Object
  • Object
show all
Includes:
Ree::FnDSL
Defined in:
lib/ree_lib/packages/ree_http/package/ree_http/functions/build_request_executor.rb

Constant Summary collapse

DEFAULTS =
{
  timeout: DEFAULT_TIMEOUT,
  write_timeout: DEFAULT_WRITE_TIMEOUT,
  force_ssl: DEFAULT_FORCE_SSL,
  proxy: {}
}.freeze

Instance Method Summary collapse

Instance Method Details

#call(uri, **opts) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ree_lib/packages/ree_http/package/ree_http/functions/build_request_executor.rb', line 38

def call(uri, **opts)
  opts = DEFAULTS.merge(opts)
  proxy = opts[:proxy] || {}

  request_executor = Net::HTTP.new(
    uri.hostname, uri.port ,
    proxy[:address], proxy[:port], proxy[:username], proxy[:password]
  )

  request_executor.write_timeout = opts[:write_timeout]
  request_executor.read_timeout = opts[:timeout]

  request_executor.use_ssl = opts[:force_ssl] || uri.scheme == HTTPS_STR


  if opts[:ca_certs?]
    request_executor = build_ca_certs(request_executor, opts[:ca_certs?])
  end

  request_executor
end