From: kazaam Date: 2007-10-09T01:30:07+09:00 Subject: Re: Can I do this perl code the same in ruby? > It seems you are trying to write a HTTP proxy. If it is not for the > educational experience then I suggest to look into the RAA or in the > standard lib. I believe a proxy class is part of Webrick. Thanks for these hints!! I didn't new about RAA which seems like a really great collection. And you have also been right with webrick which makes it pretty easy to do an http-proxy: #!/usr/bin/env ruby $Verbose=true require "webrick" require "webrick/httpproxy" pch = Proc.new{|req, res| p [ req.request_line, res.status_line ] } def upstream_proxy if prx = ENV["http_proxy"] return URI.parse(prx) end return nil end httpd = WEBrick::HTTPProxyServer.new( :Port => 10080, :ProxyContentHandler => pch, :ProxyURI => upstream_proxy ) Signal.trap(:INT){ httpd.shutdown } httpd.start -- kazaam