summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScytrin dai Kinthra <scytrin@gmail.com>2008-08-07 03:32:31 -0700
committerScytrin dai Kinthra <scytrin@gmail.com>2008-08-07 03:32:31 -0700
commitabcaaf488431fa6441e8de93265aec8318e4b277 (patch)
tree83061315c7ba54d93c3720d8f771a833b1280a49
parent90c0938c76c77353e480960bdcfeefc26ac24dbe (diff)
downloadrack-abcaaf488431fa6441e8de93265aec8318e4b277.tar.gz
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
-rw-r--r--lib/rack/session/abstract/id.rb8
-rw-r--r--lib/rack/session/memcache.rb5
-rw-r--r--test/spec_rack_session_memcache.rb2
3 files changed, 10 insertions, 5 deletions
diff --git a/lib/rack/session/abstract/id.rb b/lib/rack/session/abstract/id.rb
index 8ccd94ab..c220b2cb 100644
--- a/lib/rack/session/abstract/id.rb
+++ b/lib/rack/session/abstract/id.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 @@ module Rack
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
diff --git a/lib/rack/session/memcache.rb b/lib/rack/session/memcache.rb
index 9c6994ea..7cda9d86 100644
--- a/lib/rack/session/memcache.rb
+++ b/lib/rack/session/memcache.rb
@@ -9,11 +9,12 @@ module Rack
# 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.
diff --git a/test/spec_rack_session_memcache.rb b/test/spec_rack_session_memcache.rb
index 17d7dba6..49b6c336 100644
--- a/test/spec_rack_session_memcache.rb
+++ b/test/spec_rack_session_memcache.rb
@@ -114,5 +114,5 @@ begin
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