diff options
author | Patrick Shaughnessy <pshaughn@comcast.net> | 2020-01-24 17:51:34 -0500 |
---|---|---|
committer | Patrick Shaughnessy <pshaughn@comcast.net> | 2020-01-24 20:07:08 -0500 |
commit | 6d31827464fb4eb18dfd891fcedfd40fb955aae8 (patch) | |
tree | 17d1552d0d999215b4d95ba24a212844558fd5d5 /components/net/cookie_storage.rs | |
parent | 12693b51f510761d5dd58a9103596a192edb803c (diff) | |
download | servo-6d31827464fb4eb18dfd891fcedfd40fb955aae8.tar.gz servo-6d31827464fb4eb18dfd891fcedfd40fb955aae8.zip |
Cookies are now expired immediately before each lookup
Diffstat (limited to 'components/net/cookie_storage.rs')
-rw-r--r-- | components/net/cookie_storage.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/components/net/cookie_storage.rs b/components/net/cookie_storage.rs index 0f37ae754b9..f0815635476 100644 --- a/components/net/cookie_storage.rs +++ b/components/net/cookie_storage.rs @@ -10,6 +10,7 @@ use net_traits::pub_domains::reg_suffix; use net_traits::CookieSource; use servo_url::ServoUrl; use std::cmp::Ordering; +use std::collections::hash_map::Entry; use std::collections::HashMap; use time::{self, Tm}; @@ -144,6 +145,17 @@ impl CookieStorage { } } + pub fn remove_expired_cookies_for_url(&mut self, url: &ServoUrl) { + let domain = reg_host(url.host_str().unwrap_or("")); + if let Entry::Occupied(mut entry) = self.cookies_map.entry(domain) { + let cookies = entry.get_mut(); + cookies.retain(|c| !is_cookie_expired(&c)); + if cookies.len() == 0 { + entry.remove_entry(); + } + } + } + // http://tools.ietf.org/html/rfc6265#section-5.4 pub fn cookies_for_url(&mut self, url: &ServoUrl, source: CookieSource) -> Option<String> { let filterer = |c: &&mut Cookie| -> bool { |