mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
Add HTTP::Cookie#expire.
This commit is contained in:
parent
91193dace3
commit
d8be652a92
2 changed files with 15 additions and 0 deletions
|
|
@ -12,6 +12,8 @@ class HTTP::Cookie
|
|||
# Maximum number of bytes per cookie (RFC 6265 6.1 requires 4096 at least)
|
||||
MAX_LENGTH = 4096
|
||||
|
||||
UNIX_EPOCH = Time.at(0)
|
||||
|
||||
PERSISTENT_PROPERTIES = %w[
|
||||
name value
|
||||
domain for_domain path
|
||||
|
|
@ -347,6 +349,11 @@ class HTTP::Cookie
|
|||
Time.now > @expires
|
||||
end
|
||||
|
||||
def expire
|
||||
@expires = UNIX_EPOCH
|
||||
self
|
||||
end
|
||||
|
||||
alias secure? secure
|
||||
alias httponly? httponly
|
||||
alias session? session
|
||||
|
|
|
|||
|
|
@ -447,6 +447,14 @@ class TestHTTPCookie < Test::Unit::TestCase
|
|||
})
|
||||
end
|
||||
|
||||
def test_expiration
|
||||
cookie = HTTP::Cookie.new(cookie_values)
|
||||
|
||||
assert_equal false, cookie.expired?
|
||||
cookie.expire
|
||||
assert_equal true, cookie.expired?
|
||||
end
|
||||
|
||||
def test_equal
|
||||
assert_not_equal(HTTP::Cookie.new(cookie_values),
|
||||
HTTP::Cookie.new(cookie_values(:value => 'bar')))
|
||||
|
|
|
|||
Loading…
Reference in a new issue