mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-06-19 08:11:58 +00:00
When an HTTPS response carries a Strict-Transport-Security header, the received policy is now respected. Subsequent HTTP requests to a known HSTS host are upgraded to HTTPS before the fetch algorithm makes further decisions such as CORS and mixed content. Fixes tpexpress.co.uk, where an XHR redirects HTTPS -> HTTP -> HTTPS, relying on a HSTS policy received on the document response to avoid the CORS failure.
88 lines
2.9 KiB
C++
88 lines
2.9 KiB
C++
/*
|
|
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWebView/Application.h>
|
|
#include <LibWebView/CookieJar.h>
|
|
#include <LibWebView/HSTSStore.h>
|
|
#include <LibWebView/WebWorkerClient.h>
|
|
#include <LibWebView/WorkerProcessManager.h>
|
|
|
|
namespace WebView {
|
|
|
|
void WebWorkerClient::die()
|
|
{
|
|
WorkerProcessManager::the().worker_did_die(m_agent_id);
|
|
|
|
// Otherwise nested workers we own would outlive us, in violation of the HTML spec.
|
|
WorkerProcessManager::the().remove_web_worker_owner(*this);
|
|
}
|
|
|
|
void WebWorkerClient::did_close_worker()
|
|
{
|
|
WorkerProcessManager::the().worker_did_close(m_agent_id);
|
|
}
|
|
|
|
void WebWorkerClient::did_finish_loading_worker_script(bool worker_is_secure_context)
|
|
{
|
|
WorkerProcessManager::the().worker_did_finish_loading_script(m_agent_id, worker_is_secure_context);
|
|
}
|
|
|
|
void WebWorkerClient::did_fail_loading_worker_script()
|
|
{
|
|
WorkerProcessManager::the().worker_did_fail_loading_script(m_agent_id);
|
|
}
|
|
|
|
void WebWorkerClient::did_report_worker_exception(String message, String filename, u32 lineno, u32 colno)
|
|
{
|
|
WorkerProcessManager::the().worker_did_report_exception(m_agent_id, move(message), move(filename), lineno, colno);
|
|
}
|
|
|
|
Messages::WebWorkerClient::DidRequestCookieResponse WebWorkerClient::did_request_cookie(URL::URL url, HTTP::Cookie::Source source)
|
|
{
|
|
HTTP::Cookie::VersionedCookie cookie;
|
|
cookie.cookie = Application::cookie_jar().get_cookie(url, source);
|
|
return cookie;
|
|
}
|
|
|
|
void WebWorkerClient::did_request_file(ByteString path, i32 request_id)
|
|
{
|
|
WorkerProcessManager::the().worker_did_request_file(m_agent_id, move(path), request_id);
|
|
}
|
|
|
|
void WebWorkerClient::did_store_hsts_policy(String domain, HTTP::HSTS::ParsedHSTSPolicy policy)
|
|
{
|
|
Application::hsts_store().store_policy(domain, policy);
|
|
}
|
|
|
|
Messages::WebWorkerClient::DidIsKnownHstsHostResponse WebWorkerClient::did_is_known_hsts_host(String domain)
|
|
{
|
|
return Application::hsts_store().is_known_hsts_host(domain);
|
|
}
|
|
|
|
void WebWorkerClient::did_post_broadcast_channel_message(Web::HTML::BroadcastChannelMessage message)
|
|
{
|
|
WorkerProcessManager::the().worker_did_post_broadcast_channel_message(m_agent_id, move(message));
|
|
}
|
|
|
|
Messages::WebWorkerClient::StartWorkerAgentResponse WebWorkerClient::start_worker_agent(Web::HTML::WorkerAgentStartRequest request)
|
|
{
|
|
return WorkerProcessManager::the().start_worker_agent(*this, move(request));
|
|
}
|
|
|
|
void WebWorkerClient::close_worker_agent(Web::HTML::WorkerAgentId agent_id, Web::HTML::WorkerAgentOwnerToken owner_token)
|
|
{
|
|
WorkerProcessManager::the().close_worker_agent(*this, agent_id, owner_token);
|
|
}
|
|
|
|
WebWorkerClient::WebWorkerClient(NonnullOwnPtr<IPC::Transport> transport, Web::HTML::WorkerAgentId agent_id)
|
|
: IPC::ConnectionToServer<WebWorkerClientEndpoint, WebWorkerServerEndpoint>(*this, move(transport))
|
|
, m_agent_id(agent_id)
|
|
{
|
|
}
|
|
|
|
WebWorkerClient::~WebWorkerClient() = default;
|
|
|
|
}
|