Set content length for local files. Fixes #77

This commit is contained in:
Stephen Sykes 2017-02-22 22:59:30 +02:00
parent c89f556204
commit ab07d1fe21
2 changed files with 5 additions and 0 deletions

View File

@ -350,6 +350,7 @@ class FastImage
end
def fetch_using_file_open
@content_length = File.size?(@uri)
File.open(@uri) do |s|
fetch_using_read(s)
end

View File

@ -152,6 +152,10 @@ class FastImageTest < Test::Unit::TestCase
assert_equal info[1], FastImage.size(File.join(FixturePath, fn))
end
end
def test_should_report_content_length_correctly_for_local_files
assert_equal 3296, FastImage.new(File.join(FixturePath, "test.bmp")).content_length
end
def test_should_report_type_correctly_for_ios
GoodFixtures.each do |fn, info|