diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-05-10 16:27:55 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-12 05:47:36 +0200 |
commit | e4cb27050a19f0a1c4bfa9c65db2088dad17108f (patch) | |
tree | 5f8a6f540c47c1943fce26f8a295764db9c6c44a /Userland/Libraries | |
parent | 29d90ccf3b1cb1146573a7ff3b5e5dbe42863ce3 (diff) | |
download | serenity-e4cb27050a19f0a1c4bfa9c65db2088dad17108f.zip |
LibWeb: Implement the fetch response is CORS-cross-origin AO
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h | 2 |
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; |