mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Always respect :type parameter for send_file. Fixes GH #42
This commit is contained in:
parent
108162b343
commit
0b032a0c3e
2 changed files with 13 additions and 0 deletions
|
@ -158,6 +158,7 @@ module Sinatra
|
|||
last_modified stat.mtime
|
||||
|
||||
content_type mime_type(opts[:type]) ||
|
||||
opts[:type] ||
|
||||
mime_type(File.extname(path)) ||
|
||||
response['Content-Type'] ||
|
||||
'application/octet-stream'
|
||||
|
|
|
@ -345,6 +345,18 @@ class HelpersTest < Test::Unit::TestCase
|
|||
assert_equal 'text/plain', response['Content-Type']
|
||||
end
|
||||
|
||||
it 'sets the Content-Type response header if type option is set to a file extesion' do
|
||||
send_file_app :type => 'html'
|
||||
get '/file.txt'
|
||||
assert_equal 'text/html', response['Content-Type']
|
||||
end
|
||||
|
||||
it 'sets the Content-Type response header if type option is set to a mime type' do
|
||||
send_file_app :type => 'application/octet-stream'
|
||||
get '/file.txt'
|
||||
assert_equal 'application/octet-stream', response['Content-Type']
|
||||
end
|
||||
|
||||
it 'sets the Content-Length response header' do
|
||||
send_file_app
|
||||
get '/file.txt'
|
||||
|
|
Loading…
Add table
Reference in a new issue