def eat(url, options = {})
      limit = options.fetch(:limit, INFINITY)
      
      uri = ::URI.parse url.to_s

      body = []
      read_so_far = 0

      case uri.scheme

      when 'file', nil
        chunk_size = limit < 1_048_576 ? limit : 1_048_576
        ::File.open(uri.path, 'r') do |f|
          while chunk = f.read(chunk_size)
            break if read_so_far > limit
            read_so_far += chunk_size
            body << chunk
          end
        end

      when 'http', 'https'
        timeout = options.fetch(:timeout, TIMEOUT)
        openssl_verify_mode = options.fetch(:openssl_verify_mode, ::OpenSSL::SSL::VERIFY_PEER)
        if openssl_verify_mode == 'none'
          openssl_verify_mode = ::OpenSSL::SSL::VERIFY_NONE
        end
        http = ::HTTPClient.new
        http.agent_name = AGENT_NAME
        http.redirect_uri_callback = REDIRECT_HANDLER
        http.transparent_gzip_decompression = true
        http.receive_timeout = timeout
        if uri.scheme == 'https'
          http.ssl_config.verify_mode = openssl_verify_mode
        end
        begin
          if limit == INFINITY
            body << http.get_content(uri.to_s)
          else
            catch :stop do
              http.get_content(uri.to_s) do |chunk|
                body << chunk
                read_so_far += chunk.length
                throw :stop if read_so_far > limit
              end
            end
          end
        rescue ::HTTPClient::BadResponseError => e
          body << [e.res.body]
        end
      end

      limit == INFINITY ? body.join : body.join[0...limit]
    end
def eat(url, options = {})
      limit = options.fetch(:limit, INFINITY)
      
      uri = ::URI.parse url.to_s

      body = []
      read_so_far = 0

      case uri.scheme

      when 'file', nil
        chunk_size = limit < 1_048_576 ? limit : 1_048_576
        ::File.open(uri.path, 'r') do |f|
          while chunk = f.read(chunk_size)
            break if read_so_far > limit
            read_so_far += chunk_size
            body << chunk
          end
        end

      when 'http', 'https'
        timeout = options.fetch(:timeout, TIMEOUT)
        openssl_verify_mode = options.fetch(:openssl_verify_mode, ::OpenSSL::SSL::VERIFY_PEER)
        if openssl_verify_mode == 'none'
          openssl_verify_mode = ::OpenSSL::SSL::VERIFY_NONE
        end
        http = ::HTTPClient.new
        http.agent_name = AGENT_NAME
        http.redirect_uri_callback = REDIRECT_HANDLER
        http.transparent_gzip_decompression = true
        http.receive_timeout = timeout
        if uri.scheme == 'https'
          http.ssl_config.verify_mode = openssl_verify_mode
        end
        begin
          if limit == INFINITY
            body << http.get_content(uri.to_s)
          else
            catch :stop do
              http.get_content(uri.to_s) do |chunk|
                body << chunk
                read_so_far += chunk.length
                throw :stop if read_so_far > limit
              end
            end
          end
        rescue ::HTTPClient::BadResponseError => e
          body << [e.res.body]
        end
      end

      limit == INFINITY ? body.join : body.join[0...limit]
    end
<tt>url</tt> can be filesystem or http/https

 Options:
 * <tt>:timeout</tt> in seconds
 * <tt>:limit</tt> is characters (bytes in Ruby 1.8)
 * <tt>:openssl_verify_mode</tt> set to 'none' if you don't want to verify SSL certificates

 Example:
    eat('http://brighterplanet.com')                 #=> '...'
    eat('http://brighterplanet.com', :timeout => 10) #=> '...'
    eat('http://brighterplanet.com', :limit => 1)    #=> '.'