diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index f28e003a..17cf4c0c 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -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] = opts[:status].to_i if opts[:status].is_a?(String) halt opts[:status] || result[0], result[2] rescue Errno::ENOENT not_found diff --git a/test/helpers_test.rb b/test/helpers_test.rb index 2fd92213..22abda33 100644 --- a/test/helpers_test.rb +++ b/test/helpers_test.rb @@ -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