diff --git a/lib/http/cookie_jar/abstract_store.rb b/lib/http/cookie_jar/abstract_store.rb index f102cf6..6734854 100644 --- a/lib/http/cookie_jar/abstract_store.rb +++ b/lib/http/cookie_jar/abstract_store.rb @@ -50,6 +50,11 @@ class HTTP::CookieJar::AbstractStore self end + def delete(cookie) + raise + self + end + # Iterates over all cookies that are not expired. # # An optional argument +uri+ specifies a URI object indicating the @@ -80,7 +85,7 @@ class HTTP::CookieJar::AbstractStore else select(&:expired?) end.each { |cookie| - add(cookie.expire) + delete(cookie) } # subclasses can optionally remove over-the-limit cookies. self diff --git a/lib/http/cookie_jar/hash_store.rb b/lib/http/cookie_jar/hash_store.rb index 0e2b824..ccd6a55 100644 --- a/lib/http/cookie_jar/hash_store.rb +++ b/lib/http/cookie_jar/hash_store.rb @@ -57,7 +57,6 @@ class HTTP::CookieJar path_cookies.delete(cookie.name) self end - private :delete def each(uri = nil) now = Time.now diff --git a/lib/http/cookie_jar/mozilla_store.rb b/lib/http/cookie_jar/mozilla_store.rb index 694ec8a..a381f33 100644 --- a/lib/http/cookie_jar/mozilla_store.rb +++ b/lib/http/cookie_jar/mozilla_store.rb @@ -137,7 +137,8 @@ class HTTP::CookieJar st_update = @db.prepare("UPDATE moz_cookies SET baseDomain = :baseDomain WHERE id = :id") @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]) } @@ -214,6 +215,27 @@ class HTTP::CookieJar self 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) now = Time.now if uri @@ -230,10 +252,10 @@ class HTTP::CookieJar @db.prepare("UPDATE moz_cookies SET lastAccessed = :lastAccessed where id = :id") thost = DomainName.new(uri.host) - tpath = HTTP::Cookie.normalize_path(uri.path) + tpath = uri.path @st_cookies_for_domain.execute({ - :baseDomain => thost.domain_name.domain, + :baseDomain => thost.domain || thost.hostname, :appId => @app_id, :inBrowserElement => @in_browser_element ? 1 : 0, :expiry => now.to_i,