Permalink
Browse files

Bumped to 0.19.12, tweak to Harbor::Response#send_files to use Harbor…

…::File#name when adding files to the zip manifest response body when using mod_zip.
  • Loading branch information...
1 parent 4fa6014 commit e4543443648c059200ae83f634dc90f501239bab @Bauerpauer Bauerpauer committed Apr 27, 2011
Showing with 10 additions and 5 deletions.
  1. +1 −1 lib/harbor/response.rb
  2. +1 −1 lib/harbor/version.rb
  3. +8 −3 test/response_test.rb
View
@@ -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"
View
@@ -1,3 +1,3 @@
module Harbor
- VERSION = "0.19.11"
+ VERSION = "0.19.12"
end
View
@@ -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

0 comments on commit e454344

Please sign in to comment.