mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Cookies are now expired immediately before each lookup
This commit is contained in:
parent
12693b51f5
commit
6d31827464
7 changed files with 16 additions and 70 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue