TCPSocket in controller action

Hi,
in order to stream a file I am making use of TCPSocket. Unfortunately I
dont receive contents when in use the tcpsocket in a rails controller
action while it is working on console.

url = “http://www.google.de
version = request.env[‘HTTP_VERSION’]
verb = request.env[‘REQUEST_METHOD’]

url = request.env[‘REQUEST_URI’]

puts url

uri = URI::parse url
to_server = TCPSocket.new(uri.host, (uri.port.nil? ? 80 : uri.port))
puts “#{verb} #{url} #{version}\r\n”
to_server.write(“#{verb} #{url} #{version}\r\n”)
puts to_server
puts to_server.closed?

puts “before while”
#THIS LOOPS TAKES TOO LONG BECAUSE to_server.gets RETURNS EMTPY

while s = to_server.gets

puts s

end

puts “close”
to_server.close

Help is appreciated.
Best, Phil

I apologize for doing this double post on stackoverflow and here. but I
didn’t get a response so far.