lib/u3d/utils.rb in u3d-0.9.3 vs lib/u3d/utils.rb in u3d-0.9.4

- old
+ new

@@ -56,9 +56,19 @@ get_ssl(response['location'], redirect_limit: redirect_limit - 1) else raise "Request failed with status #{response.code}" end end + def get_url_content_length(url) + uri = URI(url) + size = nil + Net::HTTP.start(uri.host, uri.port) do |http| + response = http.request_head url + size = Integer(response['Content-Length']) + end + size + end + def hashfile(file_path, blocksize: 65_536) require 'digest' raise ArgumentError, 'Not a file' unless File.file?(file_path) md5 = Digest::MD5.new File.open(file_path, 'r') do |f|