diff options
author | Linus Groh <mail@linusgroh.de> | 2022-10-24 18:46:27 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-10-24 22:58:37 +0100 |
commit | 0a186cb460df7eb8f54b37cc5b5f2c0fbc947f7d (patch) | |
tree | 9bad3121dd7fdef2202f040309eb9e4a37e6e259 /Userland/Libraries | |
parent | c380d2cfdc1709407b77b1854517c47cbac3a137 (diff) | |
download | serenity-0a186cb460df7eb8f54b37cc5b5f2c0fbc947f7d.zip |
LibWeb: Handle filtered response in Response::clone()
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp index bd4b6141b3..d523e35f69 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <LibWeb/Bindings/MainThreadVM.h> #include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h> #include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h> @@ -92,7 +93,22 @@ WebIDL::ExceptionOr<NonnullRefPtr<Response>> Response::clone() const { // To clone a response response, run these steps: - // FIXME: 1. If response is a filtered response, then return a new identical filtered response whose internal response is a clone of response’s internal response. + auto& vm = Bindings::main_thread_vm(); + auto& realm = *vm.current_realm(); + + // 1. If response is a filtered response, then return a new identical filtered response whose internal response is a clone of response’s internal response. + if (is<FilteredResponse>(*this)) { + auto internal_response = TRY(static_cast<FilteredResponse const&>(*this).internal_response()->clone()); + if (is<BasicFilteredResponse>(*this)) + return TRY_OR_RETURN_OOM(realm, BasicFilteredResponse::create(move(internal_response))); + if (is<CORSFilteredResponse>(*this)) + return TRY_OR_RETURN_OOM(realm, CORSFilteredResponse::create(move(internal_response))); + if (is<OpaqueFilteredResponse>(*this)) + return OpaqueFilteredResponse::create(move(internal_response)); + if (is<OpaqueRedirectFilteredResponse>(*this)) + return OpaqueRedirectFilteredResponse::create(move(internal_response)); + VERIFY_NOT_REACHED(); + } // 2. Let newResponse be a copy of response, except for its body. auto new_response = Infrastructure::Response::create(); |