Permalink
Browse files

BUG: Output of date in wrong time format for cookie expiration (fixed)

Altered test output to match correct name of gem needing to be installed for memcache
  • Loading branch information...
scytrin committed Aug 7, 2008
1 parent 90c0938 commit abcaaf488431fa6441e8de93265aec8318e4b277
Showing with 10 additions and 5 deletions.
  1. +6 −2 lib/rack/session/abstract/id.rb
  2. +3 −2 lib/rack/session/memcache.rb
  3. +1 −1 test/spec_rack_session_memcache.rb
@@ -1,6 +1,8 @@
# AUTHOR: blink <blinketje@gmail.com>; blink#ruby-lang@irc.freenode.net
+# bugrep: Andreas Zehnder
require 'rack/utils'
+require 'time'
module Rack
module Session
@@ -101,11 +103,13 @@ def commit_session(env, response)
return false
end
- expiry = options[:expire_after] && time+options[:expire_after]
cookie = Utils.escape(@key)+'='+Utils.escape(sid)
cookie<< "; domain=#{options[:domain]}" if options[:domain]
cookie<< "; path=#{options[:path]}" if options[:path]
- cookie<< "; expires=#{expiry}" if expiry
+ if options[:expire_after]
+ expiry = time + options[:expire_after]
+ cookie<< "; expires=#{expiry.httpdate}"
+ end
case a = (h = response[1])['Set-Cookie']
when Array then a << cookie
@@ -9,11 +9,12 @@ module Session
# Session data is stored in memcached. The corresponding session key is
# maintained in the cookie.
# You may treat Session::Memcache as you would Session::Pool with the
- # following differences.
+ # following caveats.
#
# * Setting :expire_after to 0 would note to the Memcache server to hang
# onto the session data until it would drop it according to it's own
- # specifications.
+ # specifications. However, the cookie sent to the client would expire
+ # immediately.
#
# Note that memcache does drop data before it may be listed to expire. For
# a full description of behaviour, please see memcache's documentation.
@@ -114,5 +114,5 @@
end
end
rescue LoadError
- $stderr.puts "Skipping Rack::Session::Memcache tests (Memcache is required). `gem install memcache` and try again."
+ $stderr.puts "Skipping Rack::Session::Memcache tests (Memcache is required). `gem install memcache-client` and try again."
end

1 comment on commit abcaaf4

@qerub

This comment has been minimized.

Show comment
Hide comment
@qerub

qerub Aug 12, 2008

Contributor

Shouldn’t the time format be checked in the unit tests?

Shouldn’t the time format be checked in the unit tests?

Please sign in to comment.