mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
Add CookieJar#delete().
This commit is contained in:
parent
2ef3e42067
commit
f3b8abdd8e
2 changed files with 29 additions and 9 deletions
|
|
@ -74,6 +74,17 @@ class HTTP::CookieJar
|
|||
end
|
||||
alias << add
|
||||
|
||||
# Deletes a cookie that has the same name, domain and path as a
|
||||
# given cookie from the jar and returns self.
|
||||
#
|
||||
# How the `for_domain` flag value affects the set of deleted cookies
|
||||
# depends on the store used. See individual store classes for that
|
||||
# matter.
|
||||
def delete(cookie)
|
||||
@store.delete(cookie)
|
||||
self
|
||||
end
|
||||
|
||||
# Gets an array of cookies that should be sent for the URL/URI,
|
||||
# updating the access time of each cookie.
|
||||
def cookies(url)
|
||||
|
|
|
|||
|
|
@ -554,17 +554,26 @@ module TestHTTPCookieJar
|
|||
assert_equal('Foo1 Foo2', @jar.cookies(surl).map { |c| c.name }.sort.join(' ') )
|
||||
end
|
||||
|
||||
def _test_delete
|
||||
nurl = URI 'http://rubyforge.org/login'
|
||||
surl = URI 'https://rubyforge.org/login'
|
||||
def test_delete
|
||||
cookie1 = HTTP::Cookie.new(cookie_values)
|
||||
cookie2 = HTTP::Cookie.new(:name => 'Foo', :value => '',
|
||||
:domain => 'rubyforge.org',
|
||||
:for_domain => false,
|
||||
:path => '/')
|
||||
cookie3 = HTTP::Cookie.new(:name => 'Foo', :value => '',
|
||||
:domain => 'rubyforge.org',
|
||||
:for_domain => true,
|
||||
:path => '/')
|
||||
|
||||
cookie1 = HTTP::Cookie.new(cookie_values(:name => 'Foo1', :origin => nurl))
|
||||
cookie2 = HTTP::Cookie.new(cookie_values(:name => 'Foo1', :origin => surl))
|
||||
@jar.add(cookie1)
|
||||
@jar.delete(cookie2)
|
||||
|
||||
@jar.add(nncookie)
|
||||
@jar.add(sncookie)
|
||||
@jar.add(nscookie)
|
||||
@jar.add(sscookie)
|
||||
if mozilla_store?
|
||||
assert_equal(1, @jar.to_a.length)
|
||||
@jar.delete(cookie3)
|
||||
end
|
||||
|
||||
assert_equal(0, @jar.to_a.length)
|
||||
end
|
||||
|
||||
def test_max_cookies
|
||||
|
|
|
|||
Loading…
Reference in a new issue