Skip to content

Commit

Permalink
BUG: Output of date in wrong time format for cookie expiration (fixed)
Browse files Browse the repository at this point in the history
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 abcaaf4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib/rack/session/abstract/id.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions lib/rack/session/memcache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion test/spec_rack_session_memcache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

@qerub qerub commented on abcaaf4 Aug 12, 2008

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.