Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use RFC 2616 case for ETag and Content-MD5

  • Loading branch information...
commit 13a55c72caedfc8b177bf4d6e19c6946df9009e0 1 parent ba3c44c
Ryan Tomayko rtomayko authored
2  lib/rack/cache/context.rb
View
@@ -192,7 +192,7 @@ def validate(entry)
record :valid
entry = entry.dup
entry.headers.delete('Date')
- %w[Date Expires Cache-Control Etag Last-Modified].each do |name|
+ %w[Date Expires Cache-Control ETag Last-Modified].each do |name|
next unless value = backend_response.headers[name]
entry.headers[name] = value
end
6 lib/rack/cache/headers.rb
View
@@ -53,7 +53,7 @@ def max_age
# The literal value of the ETag HTTP header or nil if no ETag is specified.
def etag
- headers['Etag']
+ headers['ETag']
end
end
@@ -111,7 +111,7 @@ def fresh?
# uncacheable
#
# Responses with neither a freshness lifetime (Expires, max-age) nor cache
- # validator (Last-Modified, Etag) are considered uncacheable.
+ # validator (Last-Modified, ETag) are considered uncacheable.
def cacheable?
return false unless CACHEABLE_RESPONSE_CODES.include?(status)
return false if no_store? || private?
@@ -257,7 +257,7 @@ def etag_matches?(etag)
Content-Encoding
Content-Language
Content-Length
- Content-Md5
+ Content-MD5
Content-Type
Last-Modified
].to_set
14 test/context_test.rb
View
@@ -28,7 +28,7 @@
end
it 'does not cache with Authorization request header and non public response' do
- respond_with 200, 'Etag' => '"FOO"'
+ respond_with 200, 'ETag' => '"FOO"'
get '/', 'HTTP_AUTHORIZATION' => 'basic foobarbaz'
app.should.be.called
@@ -52,7 +52,7 @@
end
it 'does not cache with Cookie header and non public response' do
- respond_with 200, 'Etag' => '"FOO"'
+ respond_with 200, 'ETag' => '"FOO"'
get '/', 'HTTP_COOKIE' => 'foo=bar'
app.should.be.called
@@ -98,7 +98,7 @@
it 'responds with 304 when If-None-Match matches ETag' do
respond_with do |req,res|
res.status = 200
- res['Etag'] = '12345'
+ res['ETag'] = '12345'
res['Content-Type'] = 'text/plain'
res.body = ['Hello World']
end
@@ -109,7 +109,7 @@
response.status.should.equal 304
response.headers.should.not.include 'Content-Length'
response.headers.should.not.include 'Content-Type'
- response.headers.should.include 'Etag'
+ response.headers.should.include 'ETag'
response.body.should.empty
cache.trace.should.include :miss
cache.trace.should.include :store
@@ -280,7 +280,7 @@
end
it 'caches responses with an ETag validator but no freshness information' do
- respond_with 200, 'Etag' => '"123456"'
+ respond_with 200, 'ETag' => '"123456"'
get '/'
response.should.be.ok
@@ -473,7 +473,7 @@
get '/'
app.should.be.called
response.should.be.ok
- response.headers.should.include 'Etag'
+ response.headers.should.include 'ETag'
response.headers.should.include 'X-Content-Digest'
response.body.should.equal 'Hello World'
cache.trace.should.include :miss
@@ -483,7 +483,7 @@
get '/'
app.should.be.called
response.should.be.ok
- response.headers.should.include 'Etag'
+ response.headers.should.include 'ETag'
response.headers.should.include 'X-Content-Digest'
response['Age'].to_i.should.equal 0
response.body.should.equal 'Hello World'
4 test/headers_test.rb
View
@@ -74,8 +74,8 @@ def initialize(*args)
@res.extend Rack::Cache::ResponseHeaders
@res.should.be.validateable
end
- it 'is true when Etag header present' do
- @res = MockResponse.new(200, {'Etag' => '"12345"'}, [])
+ it 'is true when ETag header present' do
+ @res = MockResponse.new(200, {'ETag' => '"12345"'}, [])
@res.extend Rack::Cache::ResponseHeaders
@res.should.be.validateable
end
Please sign in to comment.
Something went wrong with that request. Please try again.