Created
December 31, 2012 07:38
-
-
Save jahan-paisley/4418148 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'em-http-request' | |
DEL = '-'*40 | |
@results = 0 | |
def run_with_proxy | |
connection_opts = {:proxy => {:host => '127.0.0.1', :port => 9050, :type => :socks5}} | |
conn = EM::HttpRequest.new("http://www.apolista.de/tegernsee/kloster-apotheke", connection_opts) | |
http = conn.get | |
http.callback { | |
if http.response.include? "Oops" | |
puts "#{DEL}failed with proxy#{DEL}", http.response | |
else | |
puts "#{DEL}success with proxy#{DEL}", http.response | |
end | |
@results+=1 | |
EM.stop_event_loop if @results == 2 | |
} | |
end | |
def run_without_proxy | |
conn = EM::HttpRequest.new("http://www.apolista.de/tegernsee/kloster-apotheke") | |
http = conn.get | |
http.callback { | |
if http.response.include? "Oops" | |
puts "#{DEL}failed without proxy#{DEL}", http.response | |
else | |
puts "#{DEL}success without proxy#{DEL}", http.response | |
end | |
@results+=1 | |
EM.stop_event_loop if @results == 2 | |
} | |
end | |
EM.run do | |
run_with_proxy | |
run_without_proxy | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment