title: Get file size before downloading & counting how much already downloaded (http+ruby)
body: <p>Can anybody help me to </p>
  
  <ul>
  <li>get the <strong>file size before</strong> I start downloading</li>
  <li>display how much <strong>% was already downloaded</strong></li>
  </ul>
  
  <p>.</p>
  
  <pre><code>require 'net/http'
  require 'uri'
  
  url = "http://www.onalllevels.com/2009-12-02TheYangShow_Squidoo_Part 1.flv"
  
  url_base = url.split('/')[2]
  url_path = '/'+url.split('/')[3..-1].join('/')
  
  Net::HTTP.start(url_base) do |http|
    resp = http.get(URI.escape(url_path))
    open("test.file", "wb") do |file|
      file.write(resp.body)
    end
  end
  puts "Done."
  </code></pre>