allow to set filename for send_file

if the disposition type matches "attachment", this
indicates that the recipient should prompt the user to save the response
locally, rather than process it normally
This commit is contained in:
Anton Maminov 2018-12-23 13:24:27 +02:00
parent a5d8df7382
commit 6f111ffbb0
2 changed files with 52 additions and 17 deletions

View file

@ -1,4 +1,5 @@
require "./spec_helper"
require "./handler_spec"
describe "Macros" do
describe "#public_folder" do
@ -114,6 +115,17 @@ describe "Macros" do
response.headers["Content-Type"].should eq("application/octet-stream")
response.headers["Content-Length"].should eq("6")
end
it "sends file with given path and given filename" do
get "/" do |env|
send_file env, "./spec/asset/hello.ecr", filename: "image.jpg"
end
request = HTTP::Request.new("GET", "/")
response = call_request_on_app(request)
response.status_code.should eq(200)
response.headers["Content-Disposition"].should eq("attachment; filename=\"image.jpg\"")
end
end
describe "#gzip" do