From e4cb27050a19f0a1c4bfa9c65db2088dad17108f Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 10 May 2023 16:27:55 -0400 Subject: [PATCH] LibWeb: Implement the fetch response is CORS-cross-origin AO --- .../LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp | 7 +++++++ .../Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp index c4de5f4a4e..891a46077d 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp @@ -170,6 +170,13 @@ WebIDL::ExceptionOr> Response::clone(JS::Realm& realm return new_response; } +// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-cross-origin +bool Response::is_cors_cross_origin() const +{ + // A response whose type is "opaque" or "opaqueredirect" is CORS-cross-origin. + return type() == Type::Opaque || type() == Type::OpaqueRedirect; +} + // Non-standard Optional Response::network_error_message() const { diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h index da9bfa5961..20ff11081e 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]] bool is_cors_cross_origin() const; + // Non-standard [[nodiscard]] Optional network_error_message() const;