mirror of
https://github.com/servo/servo.git
synced 2025-09-27 23:30:08 +01:00
script: initial CookieStore implementation (#37968)
This is a first draft at implementing the required infrastructure for CookieStore, which requires setting up IPC between script and the resource thread to allow for async/"in parallel" handling of cookie changes that have a promise API. Cookie Store also will need to receive change events when cookies for a url are changed so the architecture needs to support that. Expect this PR to be reworked once the architecture becomes more settled, cookie change events will be implemented in follow up PRs Testing: WPT tests exist for this API Part of #37674 --------- Signed-off-by: Sebastian C <sebsebmc@gmail.com>
This commit is contained in:
parent
a75f3fd09b
commit
b869b7eb96
35 changed files with 917 additions and 305 deletions
|
@ -205,6 +205,27 @@ impl CookieStorage {
|
|||
}
|
||||
}
|
||||
|
||||
/// <https://cookiestore.spec.whatwg.org/#query-cookies>
|
||||
pub fn query_cookies(&mut self, url: &ServoUrl, name: Option<String>) -> Vec<Cookie<'static>> {
|
||||
// 1. Retrieve cookie-list given request-uri and "non-HTTP" source
|
||||
let cookie_list = self.cookies_data_for_url(url, CookieSource::NonHTTP);
|
||||
|
||||
// 3. For each cookie in cookie-list, run these steps:
|
||||
// 3.2. If name is given, then run these steps:
|
||||
if let Some(name) = name {
|
||||
// Let cookieName be the result of running UTF-8 decode without BOM on cookie’s name.
|
||||
// If cookieName does not equal name, then continue.
|
||||
cookie_list.filter(|cookie| cookie.name() == name).collect()
|
||||
} else {
|
||||
cookie_list.collect()
|
||||
}
|
||||
|
||||
// Note: we do not convert the list into CookieListItem's here, we do that in script to not not have to define
|
||||
// the binding types in net.
|
||||
|
||||
// Return list
|
||||
}
|
||||
|
||||
pub fn cookies_data_for_url<'a>(
|
||||
&'a mut self,
|
||||
url: &'a ServoUrl,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue