Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove Response#activate!; more explicit Age header logic

  • Loading branch information...
commit 5fab53f63aa12afa88a32ed9995b4713b206d22e 1 parent 31214f5
@rtomayko rtomayko authored
View
3  lib/rack/cache/context.rb
@@ -160,6 +160,7 @@ def lookup
elsif entry = metastore.lookup(request, entitystore)
if fresh_enough?(entry)
record :fresh
+ entry.headers['Age'] = entry.age.to_s
entry
else
record :stale
@@ -192,7 +193,6 @@ def validate(entry)
next unless value = backend_response.headers[name]
entry.headers[name] = value
end
- entry.activate!
entry
else
record :invalid
@@ -235,6 +235,7 @@ def fetch
def store(response)
record :store
metastore.store(request, response, entitystore)
+ response.headers['Age'] = response.age.to_s
nil
end
end
View
2  lib/rack/cache/metastore.rb
@@ -40,7 +40,6 @@ def lookup(request, entity_store)
if body = entity_store.open(res['X-Content-Digest'])
status = res.delete('X-Status').to_i
response = Rack::Cache::Response.new(status, res, body)
- response.activate!
response
else
# TODO the metastore referenced an entity that doesn't exist in
@@ -63,7 +62,6 @@ def store(request, response, entity_store)
response.headers['X-Content-Digest'] = digest
response.headers['Content-Length'] = size.to_s unless response.headers['Transfer-Encoding']
response.body = entity_store.open(digest)
- response.activate!
end
# read existing cache entries, remove non-varying, and add this one to
View
5 lib/rack/cache/response.rb
@@ -47,11 +47,6 @@ def initialize_copy(other)
@headers = other.headers.dup
end
- # Called immediately after an object is loaded from the cache.
- def activate!
- headers['Age'] = age.to_s
- end
-
# Return the status, headers, and body in a three-tuple.
def to_a
[status, headers.to_hash, body]
View
2  test/metastore_test.rb
@@ -133,7 +133,7 @@ def self.call(request); request.path_info.reverse end
store_simple_entry
response = @store.lookup(@request, @entity_store)
response.headers.
- should.equal @response.headers.merge('Age' => '0', 'Content-Length' => '4')
+ should.equal @response.headers.merge('Content-Length' => '4')
end
it 'restores response body from entity store with #lookup' do
Please sign in to comment.
Something went wrong with that request. Please try again.