title: Ruby: abort OpenURI based on content length
body: <p>Ruby's <a href="http://www.ruby-doc.org/stdlib/libdoc/open-uri/rdoc/classes/OpenURI/OpenRead.html#M001635" rel="nofollow">OpenURI</a> provides a <code>content_length_proc</code> option which allows determining* content length before the actual transfer is started:</p>
  
  <pre><code>open(url, :content_length_proc =&gt; lambda { |content_length|
    puts "Content Length: #{content_length}"
  }) { |data|
     # data.meta, data.read etc.
  }
  </code></pre>
  
  <p>Is there a way for this proc to abort the actual, full retrieval?</p>
  
  <p>* I'm aware this is not reliable - but it's sufficient for a simple heuristic in my case</p>