Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed the case-insensitive nature of ignored response headers

  • Loading branch information...
commit 6379364deb62fade14c1268806d3ccae5811947a 1 parent 12ae92d
@rmm5t rmm5t authored
Showing with 14 additions and 1 deletion.
  1. +2 −1  lib/rack/cache/context.rb
  2. +12 −0 test/context_test.rb
View
3  lib/rack/cache/context.rb
@@ -272,7 +272,8 @@ def store(response)
# Remove all ignored response headers before writing to the cache.
def strip_ignore_headers(response)
- record :ignore if response.headers.reject! { |name, value| ignore_headers.include? name }
+ stripped_values = ignore_headers.map { |name| response.headers.delete(name) }
+ record :ignore if stripped_values.any?
end
def log_error(exception)
View
12 test/context_test.rb
@@ -97,6 +97,18 @@
response.headers['Set-Cookie'].should.be.nil
end
+ it 'does remove all configured ignore_headers from a cacheable response' do
+ respond_with 200, 'Cache-Control' => 'public', 'ETag' => '"FOO"', 'SET-COOKIE' => 'TestCookie=OK', 'X-Strip-Me' => 'Secret'
+ get '/', 'rack-cache.ignore_headers' => ['set-cookie', 'x-strip-me']
+
+ app.should.be.called
+ response.should.be.ok
+ cache.trace.should.include :store
+ cache.trace.should.include :ignore
+ response.headers['Set-Cookie'].should.be.nil
+ response.headers['x-strip-me'].should.be.nil
+ end
+
it 'does not remove Set-Cookie response header from a private response' do
respond_with 200, 'Cache-Control' => 'private', 'Set-Cookie' => 'TestCookie=OK'
get '/'
Please sign in to comment.
Something went wrong with that request. Please try again.