1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
require 'helper'
describe EventMachine do
# requires: ssh -D 8080 localhost
it "should negotiate a socks connection" do
class Handler < EM::Connection
include EM::Socksify
def connection_completed
socksify('localhost', 8082) do |ip|
send_data "GET / HTTP/1.1\r\nConnection:close\r\nHost: localhost\r\n\r\n"
end
end
def receive_data(data)
@received ||= ''
@received << data
end
def unbind
@received.size.should > 0
@received[0,4].should == 'HTTP'
EM.stop
end
end
EM.run do
EventMachine.connect '127.0.0.1', 8080, Handler
end
end
# requires squid running on localhost with default config
# it "should negotiate a connect connection" do
#
# class Handler < EM::Connection
# include EM::Connectify
# def connection_completed
# connectify('localhost', 8443) do
# start_tls
# send_data "GET / HTTP/1.1\r\nConnection:close\r\nHost: localhost\r\n\r\n"
# end
# end
# def receive_data(data)
# @received ||= ''
# @received << data
# end
# def unbind
# @received.size.should > 0
# @received[0,4].should == 'HTTP'
# EM.stop
# end
# end
# EM::run do
# EventMachine.connect '127.0.0.1', 3128, Handler
# end
# end
end
|