summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-05-10 16:57:23 -0400
committerAndreas Kling <kling@serenityos.org>2023-05-12 05:47:36 +0200
commitdff0e8a0dc56608a12081a6198b214b87812dfad (patch)
treea97edb97d0bee130cbcc47f9870357a0db94ec21 /Userland
parente4cb27050a19f0a1c4bfa9c65db2088dad17108f (diff)
downloadserenity-dff0e8a0dc56608a12081a6198b214b87812dfad.zip
LibWeb: Implement the fetch response's unsafe response AO
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp10
-rw-r--r--Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp
index 891a46077d..940beba7b6 100644
--- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp
+++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp
@@ -170,6 +170,16 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> Response::clone(JS::Realm& realm
return new_response;
}
+// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#unsafe-response
+JS::NonnullGCPtr<Response> Response::unsafe_response()
+{
+ // A response's unsafe response is its internal response if it has one, and the response itself otherwise.
+ if (is<FilteredResponse>(this))
+ return static_cast<FilteredResponse&>(*this).internal_response();
+
+ return *this;
+}
+
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-cross-origin
bool Response::is_cors_cross_origin() const
{
diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h
index 20ff11081e..58b5f0f638 100644
--- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h
+++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h
@@ -108,6 +108,8 @@ public:
[[nodiscard]] WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> clone(JS::Realm&) const;
+ [[nodiscard]] JS::NonnullGCPtr<Response> unsafe_response();
+
[[nodiscard]] bool is_cors_cross_origin() const;
// Non-standard