diff options
author | Timothy Flynn <trflynn89@pm.me> | 2021-04-14 10:36:34 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-15 09:46:49 +0200 |
commit | 347838a24025601f2a2734f0457a6d9b7aedc002 (patch) | |
tree | 59760ff94cfcb565d7d47361a51abb72ecb26db0 /Userland/Libraries/LibWeb | |
parent | 3cc5286565721335e72dc92fd688a85505ef2568 (diff) | |
download | serenity-347838a24025601f2a2734f0457a6d9b7aedc002.zip |
LibWeb: Set Cookie header on <script> resource requests
This required changing the load_sync API to take a LoadRequest instead
of just a URL. Since HTMLScriptElement was the only (non-test) user of
this API, it didn't seem useful to instead add an overload of load_sync
for this.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/ResourceLoader.h | 2 |
3 files changed, 6 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index d8293ef101..07ae682620 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -224,10 +224,12 @@ void HTMLScriptElement::prepare_script() } if (m_script_type == ScriptType::Classic) { + auto request = LoadRequest::create_for_url_on_page(url, document().page()); + // FIXME: This load should be made asynchronous and the parser should spin an event loop etc. m_script_filename = url.basename(); ResourceLoader::the().load_sync( - url, + request, [this, url](auto data, auto&, auto) { if (data.is_null()) { dbgln("HTMLScriptElement: Failed to load {}", url); diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index cd3aaeed2d..7d20b25d1d 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -52,12 +52,12 @@ ResourceLoader::ResourceLoader() { } -void ResourceLoader::load_sync(const URL& url, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback) +void ResourceLoader::load_sync(const LoadRequest& request, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback) { Core::EventLoop loop; load( - url, + request, [&](auto data, auto& response_headers, auto status_code) { success_callback(data, response_headers, status_code); loop.quit(0); diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.h b/Userland/Libraries/LibWeb/Loader/ResourceLoader.h index 74ac265f72..7eb263e8b7 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.h +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.h @@ -48,7 +48,7 @@ public: void load(const LoadRequest&, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback = nullptr); void load(const URL&, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback = nullptr); - void load_sync(const URL&, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback = nullptr); + void load_sync(const LoadRequest&, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback = nullptr); Function<void()> on_load_counter_change; |