parent
d75f12cb43
commit
1e55be7285
|
@ -164,7 +164,7 @@ module Sinatra
|
|||
# Use the contents of the file at +path+ as the response body.
|
||||
def send_file(path, opts={})
|
||||
stat = File.stat(path)
|
||||
last_modified stat.mtime
|
||||
last_modified(opts[:last_modified] || stat.mtime)
|
||||
|
||||
if opts[:type] or not response['Content-Type']
|
||||
content_type opts[:type] || File.extname(path), :default => 'application/octet-stream'
|
||||
|
|
|
@ -419,6 +419,13 @@ class HelpersTest < Test::Unit::TestCase
|
|||
assert_equal File.mtime(@file).httpdate, response['Last-Modified']
|
||||
end
|
||||
|
||||
it 'allows passing in a differen Last-Modified response header with :last_modified' do
|
||||
time = Time.now
|
||||
send_file_app :last_modified => time
|
||||
get '/file.txt'
|
||||
assert_equal time.httpdate, response['Last-Modified']
|
||||
end
|
||||
|
||||
it "returns a 404 when not found" do
|
||||
mock_app {
|
||||
get '/' do
|
||||
|
|
Loading…
Reference in New Issue