-
Notifications
You must be signed in to change notification settings - Fork 220
Proxy
igrigorik edited this page Aug 11, 2012
·
4 revisions
You can route any em-http connection through an HTTP proxy (SSL tunneling is supported):
EventMachine.run do
connection_opts = {
:proxy => {
:host => 'www.myproxy.com',
:port => 8080,
:authorization => ['username', 'password']
}
}
http = EventMachine::HttpRequest.new('http://www.website.com/', connection_opts).get
http.callback { }
end
Tunneling an em-http request connection through a SOCKS5 proxy is no more complicated than through a regular HTTP proxy:
EventMachine.run do
connection_opts = {:proxy => {:host => 'www.myproxy.com', :port => 8080, :type => :socks5 }}
http = EventMachine::HttpRequest.new('http://www.website.com/', connection_opts).get
http.callback { }
end
In both cases (HTTP and SOCKS5), the authorization is optional based on whether your proxy requires it.