summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp7
-rw-r--r--Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h2
2 files changed, 9 insertions, 0 deletions
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<JS::NonnullGCPtr<Response>> 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<StringView> 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<JS::NonnullGCPtr<Response>> clone(JS::Realm&) const;
+ [[nodiscard]] bool is_cors_cross_origin() const;
+
// Non-standard
[[nodiscard]] Optional<StringView> network_error_message() const;