Class: Faraday::Adapter::NetHttpSocks
- Inherits:
-
NetHttp
- Object
- NetHttp
- Faraday::Adapter::NetHttpSocks
- Defined in:
- lib/faraday_adapter_socks/faraday/adapter/net_http_socks.rb
Constant Summary collapse
- SOCKS_SCHEMES =
%w[socks socks4 socks5].freeze
Instance Method Summary collapse
Instance Method Details
#net_http_connection(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/faraday_adapter_socks/faraday/adapter/net_http_socks.rb', line 12 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 |