mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
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:
parent
a5d8df7382
commit
6f111ffbb0
2 changed files with 52 additions and 17 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue