mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:57:35 +00:00
Browser+WebContent+WebDriver: Move Get Named Cookie to WebContent
Instead of sending *all* cookies over IPC and filtering by name, we now filter by name from the cookie jar and send just the first matching cookie.
This commit is contained in:
parent
c6a0888088
commit
a3d6c2f6af
14 changed files with 51 additions and 57 deletions
|
@ -134,6 +134,22 @@ Vector<Web::Cookie::Cookie> CookieJar::get_all_cookies(URL const& url)
|
|||
return cookies;
|
||||
}
|
||||
|
||||
Optional<Web::Cookie::Cookie> CookieJar::get_named_cookie(URL const& url, String const& name)
|
||||
{
|
||||
auto domain = canonicalize_domain(url);
|
||||
if (!domain.has_value())
|
||||
return {};
|
||||
|
||||
auto cookie_list = get_matching_cookies(url, domain.value(), Web::Cookie::Source::Http, MatchingCookiesSpecMode::WebDriver);
|
||||
|
||||
for (auto const& cookie : cookie_list) {
|
||||
if (cookie.name == name)
|
||||
return cookie;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<String> CookieJar::canonicalize_domain(const URL& url)
|
||||
{
|
||||
// https://tools.ietf.org/html/rfc6265#section-5.1.2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue