From dff0e8a0dc56608a12081a6198b214b87812dfad Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 10 May 2023 16:57:23 -0400 Subject: LibWeb: Implement the fetch response's unsafe response AO --- .../Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp | 10 ++++++++++ .../Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h | 2 ++ 2 files changed, 12 insertions(+) (limited to 'Userland/Libraries') 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> Response::clone(JS::Realm& realm return new_response; } +// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#unsafe-response +JS::NonnullGCPtr Response::unsafe_response() +{ + // A response's unsafe response is its internal response if it has one, and the response itself otherwise. + if (is(this)) + return static_cast(*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> clone(JS::Realm&) const; + [[nodiscard]] JS::NonnullGCPtr unsafe_response(); + [[nodiscard]] bool is_cors_cross_origin() const; // Non-standard -- cgit v1.2.3