Skip to content

Commit

Permalink
Rack::ConditionalGet: check for ETag header, not Etag
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Mar 4, 2010
1 parent f10713c commit e59456a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rack/conditionalget.rb
Expand Up @@ -4,7 +4,7 @@ module Rack

# Middleware that enables conditional GET using If-None-Match and
# If-Modified-Since. The application should set either or both of the
# Last-Modified or Etag response headers according to RFC 2616. When
# Last-Modified or ETag response headers according to RFC 2616. When
# either of the conditions is met, the response body is set to be zero
# length and the response status is set to 304 Not Modified.
#
Expand Down Expand Up @@ -35,7 +35,7 @@ def call(env)

private
def etag_matches?(env, headers)
etag = headers['Etag'] and etag == env['HTTP_IF_NONE_MATCH']
etag = headers['ETag'] and etag == env['HTTP_IF_NONE_MATCH']
end

def modified_since?(env, headers)
Expand Down
10 changes: 10 additions & 0 deletions test/spec_rack_conditionalget.rb
Expand Up @@ -38,4 +38,14 @@
response.status.should.equal 200
response.body.should.equal 'TEST'
end

specify "should work with ETag headers, not just Etag" do
app = Rack::ConditionalGet.new(lambda { |env|
[200, {'ETag'=>'1234'}, ['TEST']] })

status, headers, body = app.call('REQUEST_METHOD' => 'GET', 'HTTP_IF_NONE_MATCH' => '1234')

status.should.equal 304
body.should.be.empty
end
end

0 comments on commit e59456a

Please sign in to comment.