last_modified ignores nil
This commit is contained in:
parent
035fe4705d
commit
3ff226272a
|
@ -240,6 +240,7 @@ module Sinatra
|
|||
# matches the time specified, execution is immediately halted with a
|
||||
# '304 Not Modified' response.
|
||||
def last_modified(time)
|
||||
return unless time
|
||||
time = time.to_time if time.respond_to?(:to_time)
|
||||
time = time.httpdate if time.respond_to?(:httpdate)
|
||||
response['Last-Modified'] = time
|
||||
|
|
|
@ -451,6 +451,15 @@ class HelpersTest < Test::Unit::TestCase
|
|||
assert_equal 304, status
|
||||
assert_equal '', body
|
||||
end
|
||||
|
||||
it 'ignores nil' do
|
||||
mock_app {
|
||||
get '/' do last_modified nil; 200; end
|
||||
}
|
||||
|
||||
get '/'
|
||||
assert ! response['Last-Modified']
|
||||
end
|
||||
end
|
||||
|
||||
describe 'etag' do
|
||||
|
|
Loading…
Reference in New Issue