Permalink
Browse files

BugFix in ConditionalGet; don't crash when we get a malformed HTTP_IF…

…_MODIFIED_SINCE timestamp
  • Loading branch information...
1 parent 4425e37 commit 68dd85f6288ac8014c395c801c254ba69b29efbb @mulder mulder committed Aug 31, 2011
Showing with 13 additions and 0 deletions.
  1. +1 −0 lib/rack/conditionalget.rb
  2. +12 −0 test/spec_conditionalget.rb
@@ -56,6 +56,7 @@ def etag_matches?(none_match, headers)
def modified_since?(modified_since, headers)
last_modified = to_rfc2822(headers['Last-Modified']) and
+ modified_since and
modified_since >= last_modified
end
@@ -83,4 +83,16 @@
response.body.should.equal 'TEST'
end
+ should "not affect requests with malformed HTTP_IF_NONE_MATCH" do
+ bad_timestamp = Time.now.strftime('%Y-%m-%d %H:%M:%S %z')
+ app = Rack::ConditionalGet.new(lambda { |env|
+ [200,{'Last-Modified'=>(Time.now - 3600).httpdate}, ['TEST']] })
+
+ response = Rack::MockRequest.new(app).
+ get("/", 'HTTP_IF_MODIFIED_SINCE' => bad_timestamp)
+
+ response.status.should.equal 200
+ response.body.should.equal 'TEST'
+ end
+
end

0 comments on commit 68dd85f

Please sign in to comment.