module Faraday::Adapter::HTTPX::RequestMixin

  1. lib/httpx/adapters/faraday.rb

Methods

Public Instance

  1. build_connection
  2. close

Public Instance methods

build_connection(env)
[show source]
   # File lib/httpx/adapters/faraday.rb
16 def build_connection(env)
17   return @connection if @connection
18 
19   @connection = ::HTTPX.plugin(:persistent).plugin(ReasonPlugin)
20   @connection = @connection.with(@connection_options) unless @connection_options.empty?
21   connection_opts = options_from_env(env)
22 
23   if (bind = env.request.bind)
24     @bind = TCPSocket.new(bind[:host], bind[:port])
25     connection_opts[:io] = @bind
26   end
27   @connection = @connection.with(connection_opts)
28 
29   if (proxy = env.request.proxy)
30     proxy_options = { uri: proxy.uri }
31     proxy_options[:username] = proxy.user if proxy.user
32     proxy_options[:password] = proxy.password if proxy.password
33 
34     @connection = @connection.plugin(:proxy).with(proxy: proxy_options)
35   end
36   @connection = @connection.plugin(OnDataPlugin) if env.request.stream_response?
37 
38   @connection = @config_block.call(@connection) || @connection if @config_block
39   @connection
40 end
close()
[show source]
   # File lib/httpx/adapters/faraday.rb
42 def close
43   @connection.close if @connection
44   @bind.close if @bind
45 end