-
-
Save peck/3320350 to your computer and use it in GitHub Desktop.
HTTP over SOCKS support monkey patch for Mechanize, Faraday and it's based clients (OAuth2 like)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# requires socksify gem | |
require "socksify" | |
require 'socksify/http' | |
#updated to work with latest Faraday | |
class Faraday::Adapter::NetHttp | |
def net_http_connection(env) | |
if proxy = env[:request][:proxy] | |
Net::HTTP::Proxy(proxy[:uri].host, proxy[:uri].port, proxy[:user], proxy[:password]) | |
else | |
Net::HTTP | |
end.new(env[:url].host, env[:url].port) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment