diff options
| author | José Valim <jose.valim@gmail.com> | 2012-04-30 06:27:01 -0700 | 
|---|---|---|
| committer | José Valim <jose.valim@gmail.com> | 2012-04-30 06:27:01 -0700 | 
| commit | 09de707f258829030e643fad872a882eaa8ed190 (patch) | |
| tree | ef7012d1b1428bd9cd6d120252f625c536010472 /actionpack/lib | |
| parent | 6be5999c7d803615cdbbfd92c229ec601ddd56b4 (diff) | |
| parent | 2d18dd34719b1f9a3d2e3a516ccb83e7067dcd91 (diff) | |
| download | rails-09de707f258829030e643fad872a882eaa8ed190.tar.gz rails-09de707f258829030e643fad872a882eaa8ed190.tar.bz2 rails-09de707f258829030e643fad872a882eaa8ed190.zip  | |
Merge pull request #6082 from brainopia/smarter_cookie_jar
Stream cookies only if needed
Diffstat (limited to 'actionpack/lib')
| -rw-r--r-- | actionpack/lib/action_dispatch/middleware/cookies.rb | 17 | 
1 files changed, 10 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb index 2f17bf8b9e..196f655de3 100644 --- a/actionpack/lib/action_dispatch/middleware/cookies.rb +++ b/actionpack/lib/action_dispatch/middleware/cookies.rb @@ -82,7 +82,7 @@ module ActionDispatch      TOKEN_KEY   = "action_dispatch.secret_token".freeze      # Raised when storing more than 4K of session data. -    class CookieOverflow < StandardError; end +    CookieOverflow = Class.new StandardError      class CookieJar #:nodoc:        include Enumerable @@ -153,7 +153,7 @@ module ActionDispatch            end          elsif options[:domain].is_a? Array            # if host matches one of the supplied domains without a dot in front of it -          options[:domain] = options[:domain].find {|domain| @host.include? domain[/^\.?(.*)$/, 1] } +          options[:domain] = options[:domain].find {|domain| @host.include? domain.sub(/^\./, '') }          end        end @@ -168,12 +168,14 @@ module ActionDispatch            options = { :value => value }          end -        @cookies[key.to_s] = value -          handle_options(options) -        @set_cookies[key.to_s] = options -        @delete_cookies.delete(key.to_s) +        if @cookies[key.to_s] != value or options[:expires] +          @cookies[key.to_s] = value +          @set_cookies[key.to_s] = options +          @delete_cookies.delete(key.to_s) +        end +          value        end @@ -181,8 +183,9 @@ module ActionDispatch        # and setting its expiration date into the past. Like <tt>[]=</tt>, you can pass in        # an options hash to delete cookies with extra data such as a <tt>:path</tt>.        def delete(key, options = {}) -        options.symbolize_keys! +        return unless @cookies.has_key? key.to_s +        options.symbolize_keys!          handle_options(options)          value = @cookies.delete(key.to_s)  | 
