mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-04-27 14:57:46 +00:00
Officially add AbstractStore#delete() as an API method.
This commit is contained in:
parent
19901a9d9c
commit
30e2915c1e
3 changed files with 31 additions and 5 deletions
|
|
@ -50,6 +50,11 @@ class HTTP::CookieJar::AbstractStore
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete(cookie)
|
||||||
|
raise
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
# Iterates over all cookies that are not expired.
|
# Iterates over all cookies that are not expired.
|
||||||
#
|
#
|
||||||
# An optional argument +uri+ specifies a URI object indicating the
|
# An optional argument +uri+ specifies a URI object indicating the
|
||||||
|
|
@ -80,7 +85,7 @@ class HTTP::CookieJar::AbstractStore
|
||||||
else
|
else
|
||||||
select(&:expired?)
|
select(&:expired?)
|
||||||
end.each { |cookie|
|
end.each { |cookie|
|
||||||
add(cookie.expire)
|
delete(cookie)
|
||||||
}
|
}
|
||||||
# subclasses can optionally remove over-the-limit cookies.
|
# subclasses can optionally remove over-the-limit cookies.
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ class HTTP::CookieJar
|
||||||
path_cookies.delete(cookie.name)
|
path_cookies.delete(cookie.name)
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
private :delete
|
|
||||||
|
|
||||||
def each(uri = nil)
|
def each(uri = nil)
|
||||||
now = Time.now
|
now = Time.now
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,8 @@ class HTTP::CookieJar
|
||||||
st_update = @db.prepare("UPDATE moz_cookies SET baseDomain = :baseDomain WHERE id = :id")
|
st_update = @db.prepare("UPDATE moz_cookies SET baseDomain = :baseDomain WHERE id = :id")
|
||||||
|
|
||||||
@db.execute("SELECT id, host FROM moz_cookies") { |row|
|
@db.execute("SELECT id, host FROM moz_cookies") { |row|
|
||||||
domain = DomainName.new(row[:host]).domain
|
domain_name = DomainName.new(row[:host])
|
||||||
|
domain = domain_name.domain || domain_name.hostname
|
||||||
st_update.execute(:baseDomain => domain, :id => row[:id])
|
st_update.execute(:baseDomain => domain, :id => row[:id])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -214,6 +215,27 @@ class HTTP::CookieJar
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete(cookie)
|
||||||
|
@st_delete ||=
|
||||||
|
@db.prepare(<<-'SQL')
|
||||||
|
DELETE FROM moz_cookies
|
||||||
|
WHERE appId = :appId AND
|
||||||
|
inBrowserElement = :inBrowserElement AND
|
||||||
|
name = :name AND
|
||||||
|
host = :host AND
|
||||||
|
path = :path
|
||||||
|
SQL
|
||||||
|
|
||||||
|
@st_delete.execute({
|
||||||
|
:appId => @app_id,
|
||||||
|
:inBrowserElement => @in_browser_element ? 1 : 0,
|
||||||
|
:name => cookie.name,
|
||||||
|
:host => cookie.dot_domain,
|
||||||
|
:path => cookie.path,
|
||||||
|
})
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
def each(uri = nil)
|
def each(uri = nil)
|
||||||
now = Time.now
|
now = Time.now
|
||||||
if uri
|
if uri
|
||||||
|
|
@ -230,10 +252,10 @@ class HTTP::CookieJar
|
||||||
@db.prepare("UPDATE moz_cookies SET lastAccessed = :lastAccessed where id = :id")
|
@db.prepare("UPDATE moz_cookies SET lastAccessed = :lastAccessed where id = :id")
|
||||||
|
|
||||||
thost = DomainName.new(uri.host)
|
thost = DomainName.new(uri.host)
|
||||||
tpath = HTTP::Cookie.normalize_path(uri.path)
|
tpath = uri.path
|
||||||
|
|
||||||
@st_cookies_for_domain.execute({
|
@st_cookies_for_domain.execute({
|
||||||
:baseDomain => thost.domain_name.domain,
|
:baseDomain => thost.domain || thost.hostname,
|
||||||
:appId => @app_id,
|
:appId => @app_id,
|
||||||
:inBrowserElement => @in_browser_element ? 1 : 0,
|
:inBrowserElement => @in_browser_element ? 1 : 0,
|
||||||
:expiry => now.to_i,
|
:expiry => now.to_i,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue