diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-02-18 00:47:18 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-02-18 00:47:18 +0000 |
commit | 4fd84aae90e940b1a33429c4c5f9872fec777b80 (patch) | |
tree | b847f0984f2b84550f8d28bffc6fa60a0aab712f /actionpack/lib | |
parent | 392c7f7314d196c54912a65981d79002d032f896 (diff) | |
download | rails-4fd84aae90e940b1a33429c4c5f9872fec777b80.tar.gz rails-4fd84aae90e940b1a33429c4c5f9872fec777b80.tar.bz2 rails-4fd84aae90e940b1a33429c4c5f9872fec777b80.zip |
Etagging ignores appended and block responses.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6160 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-x | actionpack/lib/action_controller/base.rb | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index e870dc3045..524d11de50 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -7,7 +7,7 @@ require 'action_controller/url_rewriter' require 'action_controller/status_codes' require 'drb' require 'set' -require 'md5' +require 'digest/md5' module ActionController #:nodoc: class ActionControllerError < StandardError #:nodoc: @@ -876,17 +876,19 @@ module ActionController #:nodoc: response.body << text else response.body = text - end - if response.headers['Status'] == "200 OK" && response.body.size > 0 - response.headers['Etag'] = "\"#{MD5.new(text).to_s}\"" - - if request.headers['HTTP_IF_NONE_MATCH'] == response.headers['Etag'] - response.headers['Status'] = "304 Not Modified" - response.body = '' + if text.is_a?(String) + if response.headers['Status'][0..2] == '200' && !response.body.empty? + response.headers['Etag'] = %("#{Digest::MD5.hexdigest(text)}") + + if request.headers['HTTP_IF_NONE_MATCH'] == response.headers['Etag'] + response.headers['Status'] = "304 Not Modified" + response.body = '' + end + end end end - + response.body end |