diff --git a/lib/harbor/response.rb b/lib/harbor/response.rb index 4009aa1..7887c3f 100644 --- a/lib/harbor/response.rb +++ b/lib/harbor/response.rb @@ -123,7 +123,7 @@ def send_files(name, files) if @request.env["HTTP_MOD_ZIP_ENABLED"] files.each do |file| path = ::File.expand_path(file.path) - puts("#{Zlib.crc32(::File.read(path)).to_s(16)} #{::File.size(path)} #{path} #{::File.basename(path)}") + puts("#{Zlib.crc32(::File.read(path)).to_s(16)} #{::File.size(path)} #{path} #{file.name}") end headers["X-Archive-Files"] = "zip" self.content_type = "application/zip" diff --git a/lib/harbor/version.rb b/lib/harbor/version.rb index 43f7770..cb63be1 100644 --- a/lib/harbor/version.rb +++ b/lib/harbor/version.rb @@ -1,3 +1,3 @@ module Harbor - VERSION = "0.19.11" + VERSION = "0.19.12" end diff --git a/test/response_test.rb b/test/response_test.rb index 68f41d6..2593de2 100644 --- a/test/response_test.rb +++ b/test/response_test.rb @@ -279,14 +279,19 @@ def test_nginx_stream_file_with_harbor_file_and_x_sendfile_with_mapping # nginx ModZip tests ## - def test_nginx_mod_zip_send_files_has_properly_formatting_body + def test_nginx_mod_zip_send_files_has_properly_formatted_body @request.env["HTTP_MOD_ZIP_ENABLED"] = "True" file = Harbor::File.new(Pathname(__FILE__)) + file.name = "My Custom Filename.rb" - @response.send_files("test", [file]) + @response.send_files("test.zip", [file]) + + assert_equal "#{Zlib.crc32(File.read(file.path)).to_s(16)} #{File.size(file.path)} #{File.expand_path(file.path)} #{file.name}\n", @response.buffer - assert_equal @response.buffer, "#{Zlib.crc32(File.read(file.path)).to_s(16)} #{File.size(file.path)} #{File.expand_path(file.path)} #{File.basename(file.path)}\n" + assert_equal "zip", @response.headers["X-Archive-Files"] + assert_equal "attachment; filename=\"test.zip\"", @response.headers["Content-Disposition"] + assert_equal "application/zip", @response.headers["Content-Type"] end def test_nginx_mod_zip_has_appropriate_header