I use the following code to download a number of files from a remote web 
site.  Sometimes for some reasons, the downloading never get finished, and 
the script is waiting indefinitely for the supposed coming data.  Then, I 
must interrupt with CTRL-C and check manually for the missing files and 
start the process again for the missing ones.

Is there a way to raise an error if the the connection get stuck and no 
data is coming throught the http connection for a configurable length of 
time?

Thanks


filenames=[an array of filenames]
http=Net::HTTP.new(hostname)
http.start
filenames.each do |file|
  puts "Downloading #{file}"
  resp, data=http.get(file)
  local=File.new(file, 'w')
  local.write(data)
  local.close
end