require 'net/http' require 'webrick/httpproxy' describe "web proxy" do if false it "shoudld refer to a global_web_server through a global_application_interface" do b=TestBed.new b.run("UdpNetwork") b.run("DirectoryService") ns=b.run("NameService") sleep 2 ns.export("test.appswarm","myInstance") b.run("GlobalWebServer") b.run("GlobalApplicationInterface") proxy=b.run("GlobalWebProxy") proxy["test.appswarm"].get("CHECK").should == "RETURN [CHECK]" b.stop end end it "should be possible to access redmine on 127.0.0.1 3000" do Net::HTTP.start("127.0.0.1",3000){|http| pp http.get("/") } 1.should == 1 end it "should be possible to access redmine across a proxy" do proxy_port=9999 proxy_addr="127.0.0.1" proxy=WEBrick::HTTPProxyServer.new(:BindAddress=>proxy_addr,:Port=>proxy_port) t2=Thread.new {proxy.start} Net::HTTP::Proxy(proxy_addr, proxy_port).start('127.0.0.1','3000') {|http| puts "HTTP OPENED" #t=Thread.new { begin result=http.get("/") rescue Object=>e pp e,e.backtrace end #} #sleep 5 #t.raise Exception.new puts "GETTTT" pp result proxy.shutdown } end it "should work on a proxy-connection" do b=TestBed.new b.run("UdpNetwork") b.run("DirectoryService") ns=b.run("NameService") sleep 2 ns.export("test.appswarm","myInstance") b.run("GlobalWebServer") b.run("GlobalApplicationInterface") proxy=b.run("GlobalWebProxy") sleep 2 proxy_addr = '127.0.0.1' proxy_port = proxy.port puts "TRYING PROXY #{proxy_addr} #{proxy_port}" Net::HTTP::Proxy(proxy_addr, proxy_port).start('test.appswarm') {|http| puts "HTTP OPENED" result=nil begin result=http.get("/?arg1=p1") rescue Object=>e pp e,e.backtrace end pp "PROXY_RESULT:",result pp result.body } b.stop end end