class Faraday::Adapter::NetHttpSocks

Constants

SOCKS_SCHEMES

Public Instance Methods

net_http_connection(env) click to toggle source
# File lib/faraday/adapter/net_http_socks.rb, line 10
def net_http_connection(env)
  proxy = env[:request][:proxy]

  net_http_class = if proxy
    if SOCKS_SCHEMES.include?(proxy[:uri].scheme)
      Net::HTTP::SOCKSProxy(proxy[:uri].host, proxy[:uri].port)
    else
      Net::HTTP::Proxy(proxy[:uri].host, proxy[:uri].port, proxy[:user], proxy[:password])
    end
  else
    Net::HTTP
  end

  net_http_class.new(env[:url].host, env[:url].port)
end