mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 17:29:01 +00:00
LibWeb: Receive cookies through principal_host_defined_page
Previously we depended on an associated document on the ESO to get to the page, but Workers do not have documents. However, we can simply get to the page with `principal_host_defined_page`, removing the issue.
This commit is contained in:
parent
905e749575
commit
05438e70f1
Notes:
github-actions[bot]
2025-09-09 13:29:46 +00:00
Author: https://github.com/Lubrsi
Commit: 05438e70f1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6116
2 changed files with 4 additions and 12 deletions
|
@ -1944,11 +1944,8 @@ WebIDL::ExceptionOr<GC::Ref<PendingResponse>> http_network_or_cache_fetch(JS::Re
|
||||||
// 1. Let cookies be the result of running the "cookie-string" algorithm (see section 5.4 of [COOKIES])
|
// 1. Let cookies be the result of running the "cookie-string" algorithm (see section 5.4 of [COOKIES])
|
||||||
// with the user agent’s cookie store and httpRequest’s current URL.
|
// with the user agent’s cookie store and httpRequest’s current URL.
|
||||||
auto cookies = ([&] {
|
auto cookies = ([&] {
|
||||||
// FIXME: Getting to the page client reliably is way too complicated, and going via the document won't work in workers.
|
auto& page = Bindings::principal_host_defined_page(HTML::principal_realm(realm));
|
||||||
auto document = Bindings::principal_host_defined_environment_settings_object(HTML::principal_realm(realm)).responsible_document();
|
return page.client().page_did_request_cookie(http_request->current_url(), Cookie::Source::Http);
|
||||||
if (!document)
|
|
||||||
return String {};
|
|
||||||
return document->page().client().page_did_request_cookie(http_request->current_url(), Cookie::Source::Http);
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// 2. If cookies is not the empty string, then append (`Cookie`, cookies) to httpRequest’s header list.
|
// 2. If cookies is not the empty string, then append (`Cookie`, cookies) to httpRequest’s header list.
|
||||||
|
|
|
@ -200,13 +200,8 @@ ErrorOr<void> WebSocket::establish_web_socket_connection(URL::URL const& url_rec
|
||||||
HTTP::HeaderMap additional_headers;
|
HTTP::HeaderMap additional_headers;
|
||||||
|
|
||||||
auto cookies = ([&] {
|
auto cookies = ([&] {
|
||||||
// FIXME: Getting to the page client reliably is way too complicated, and going via the document won't work in workers.
|
auto& page = Bindings::principal_host_defined_page(HTML::principal_realm(realm()));
|
||||||
auto document = client.responsible_document();
|
return page.client().page_did_request_cookie(url_record, Cookie::Source::Http);
|
||||||
if (!document)
|
|
||||||
return String {};
|
|
||||||
|
|
||||||
// NOTE: The WebSocket handshake is sent as an HTTP request, so the source should be Http.
|
|
||||||
return document->page().client().page_did_request_cookie(url_record, Cookie::Source::Http);
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
if (!cookies.is_empty()) {
|
if (!cookies.is_empty()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue