mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Merge pull request #787 from somu/static-send-file-fix
#send_file indifferent :status option
This commit is contained in:
commit
7948494fdf
2 changed files with 12 additions and 0 deletions
|
@ -366,6 +366,7 @@ module Sinatra
|
||||||
result = file.serving env
|
result = file.serving env
|
||||||
result[1].each { |k,v| headers[k] ||= v }
|
result[1].each { |k,v| headers[k] ||= v }
|
||||||
headers['Content-Length'] = result[1]['Content-Length']
|
headers['Content-Length'] = result[1]['Content-Length']
|
||||||
|
opts[:status] &&= Integer(opts[:status])
|
||||||
halt opts[:status] || result[0], result[2]
|
halt opts[:status] || result[0], result[2]
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
not_found
|
not_found
|
||||||
|
|
|
@ -905,6 +905,17 @@ class HelpersTest < Test::Unit::TestCase
|
||||||
get '/'
|
get '/'
|
||||||
assert_equal 'image/gif', response['Content-Type']
|
assert_equal 'image/gif', response['Content-Type']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'can have :status option as a string' do
|
||||||
|
path = @file
|
||||||
|
mock_app do
|
||||||
|
post '/' do
|
||||||
|
send_file path, :status => '422'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
post '/'
|
||||||
|
assert_equal response.status, 422
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'cache_control' do
|
describe 'cache_control' do
|
||||||
|
|
Loading…
Reference in a new issue