Skip to content

Commit

Permalink
fix issues w/ frozen original response
Browse files Browse the repository at this point in the history
  • Loading branch information
rtomayko committed Oct 20, 2008
1 parent 5b59ea2 commit 0356b30
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/rack/cache/core.rb
Expand Up @@ -98,8 +98,9 @@ def not_modified?
# Delegate the request to the backend and create the response.
def fetch_from_backend
status, headers, body = backend.call(request.env)
@original_response = Response.new(status, headers.dup.freeze, body)
@response = Response.new(status, headers, body)
response = Response.new(status, headers, body)
@response = response.dup
@original_response = response.freeze
end

private
Expand Down Expand Up @@ -136,6 +137,7 @@ def perform_lookup
trace 'cache hit (ttl: %ds)', @object.ttl
transition(from=:hit, to=[:deliver, :pass, :error]) do |event|
@response = @object if event == :deliver
event
end
else
trace 'cache stale (ttl: %ds), validating...', @object.ttl
Expand Down
5 changes: 5 additions & 0 deletions lib/rack/cache/response.rb
Expand Up @@ -42,6 +42,11 @@ def dup
object
end

def freeze
@headers.freeze
super
end

end

end

0 comments on commit 0356b30

Please sign in to comment.