Open yarafan opened 6 years ago
I was able to fix it by monkey patching Faraday::Adapter::NetHttp, but I am not sure that was the best decision
Hi @yarafan, thanks for reporting.
Can I ask you how you monkey-patched Faraday::Adapter::NetHttp
?
i use gem 'socksify'
require "socksify/http"
class Faraday::Adapter::NetHttp
def net_http_connection(env)
if (proxy = env[:request][:proxy])
proxy_class(proxy)
else
Net::HTTP
end.new(env[:url].hostname, env[:url].port || (env[:url].scheme == "https" ? 443 : 80))
end
def proxy_class(proxy)
if proxy.uri.scheme == "socks"
TCPSocket.socks_username = proxy[:user] if proxy[:user]
TCPSocket.socks_password = proxy[:password] if proxy[:password]
Net::HTTP::SOCKSProxy(proxy[:uri].host, proxy[:uri].port)
else
Net::HTTP::Proxy(proxy[:uri].host, proxy[:uri].port, proxy[:uri].user, proxy[:uri].password)
end
end
end
@yarafan I see, so basically Net::HTTP
doesn't support socks proxy out-of-the-box.
In this case I wouldn't classify this as a bug, but more as a feature request to support socks proxies.
As any other feature request, this should be solved for all adapters in the current 0.x branch, however for the v1.0 branch we're moving all adapters out of faraday and keeping only Net::HTTP in.
That will be a good time to introduce this 👍
I'll update the title and label the Issue, if anyone needs to use socks proxies before then, they can use your monkey-patch
Add authentication support to Net::HTTP.SOCKSProxy https://github.com/astro/socksify-ruby/pull/24/files
I am looking for doing exactly this
Good job @yarafan
Hi there. What's the status about this feature ? Is it still under development ? I would be very much interested not to have to use a monkey patch to do this
@gcolson yes @technoweenie did most of the job already 🎉 Unfortunately, however, we're currently waiting for a dependent PR to be merged, see my comment: https://github.com/lostisland/faraday/pull/992#issuecomment-508437342
Basic Info
Issue description
Using socks proxy with auth leads to Faraday::ConnectionFailed: end of file reached
Steps to reproduce
Initialize Faraday
and make any request