Skip to content

Commit

Permalink
Bumped to 0.19.12, tweak to Harbor::Response#send_files to use Harbor…
Browse files Browse the repository at this point in the history
…::File#name when adding files to the zip manifest response body when using mod_zip.
  • Loading branch information
Bauerpauer committed Apr 27, 2011
1 parent 4fa6014 commit e454344
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/harbor/response.rb
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion lib/harbor/version.rb
@@ -1,3 +1,3 @@
module Harbor
VERSION = "0.19.11"
VERSION = "0.19.12"
end
11 changes: 8 additions & 3 deletions test/response_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit e454344

Please sign in to comment.