Ruby 使用tor作为代理时em http请求意外结果
我已经创建了一个要点,它准确地显示了所发生的事情。Ruby 使用tor作为代理时em http请求意外结果,ruby,eventmachine,tor,em-http-request,Ruby,Eventmachine,Tor,Em Http Request,我已经创建了一个要点,它准确地显示了所发生的事情。 我已经测试了一个使用ruby的'net/http'库和'socksify/http'的版本,它工作得很好,但是如果EventMachine版本返回意外的结果。 Tor浏览器中的响应正确,但使用EventMachine不正确 它返回一个响应,但与通过浏览器、net/http(带代理或不带代理)发送请求时返回的响应不同 为了方便起见,我也会把它贴在这里 require 'em-http-request' DEL = '-'*40 @result
我已经测试了一个使用ruby的'net/http'库和'socksify/http'的版本,它工作得很好,但是如果EventMachine版本返回意外的结果。
Tor浏览器中的响应正确,但使用EventMachine不正确 它返回一个响应,但与通过浏览器、net/http(带代理或不带代理)发送请求时返回的响应不同 为了方便起见,我也会把它贴在这里
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
请澄清