1
0
Fork 0
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:
Konstantin Haase 2013-09-25 06:24:53 -07:00
commit 7948494fdf
2 changed files with 12 additions and 0 deletions

View file

@ -366,6 +366,7 @@ module Sinatra
result = file.serving env
result[1].each { |k,v| headers[k] ||= v }
headers['Content-Length'] = result[1]['Content-Length']
opts[:status] &&= Integer(opts[:status])
halt opts[:status] || result[0], result[2]
rescue Errno::ENOENT
not_found

View file

@ -905,6 +905,17 @@ class HelpersTest < Test::Unit::TestCase
get '/'
assert_equal 'image/gif', response['Content-Type']
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
describe 'cache_control' do