From: Tanner Burson Date: 2005-04-22T09:54:20+09:00 Subject: Proxy Server troubles I've been working on a proxy server implementation for a project idea I have. But I've found that it only seems to work on certain pages, and not on others. I've distilled the problem down to a simple implementation, but it still occurs. The code below will return a (mostly) correct website if pointed at 'www.msn.com' but if pointed at say 'slashdot.org' the browser refuses to display it, in both cases the page is loaded correctly. If anyone has any ideas I'd really appreciate it. ===proxy.rb require 'socket' require 'net/http' local_host = '192.168.0.6' local_port = 8080 host = 'slashdot.org' server = TCPServer.new(local_host,local_port) while true Thread.start(server.accept) do |s| data = '' while s.gets && !$_.nil? data += $_ break if $_ == "\r\n" || $_ == "\n" end p "====Received: #{data}" net = Net::HTTP.new(host,80) response = net.get('/') s << "HTTP/#{response.http_version} #{response.code}/#{response.message} \r\n" p "====Got back" response.each_header do |key,value| tmp = key + ": " + value + "\r\n" p tmp s << tmp end p response.body s << "\r\n" << response.body s.close # We're done with this request, bring on the next. end end ====end -- ===Tanner Burson=== tanner.burson@gmail.com http://tannerburson.com <---Might even work one day...