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