1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:07:35 +00:00

LibWeb: Implement the CORS settings attribute credentials mode AO

This commit is contained in:
Timothy Flynn 2023-05-10 16:24:52 -04:00 committed by Andreas Kling
parent 9070aaebee
commit 9701128145
2 changed files with 22 additions and 0 deletions

View file

@ -26,4 +26,24 @@ CORSSettingAttribute cors_setting_attribute_from_keyword(Optional<String> const&
return CORSSettingAttribute::Anonymous; return CORSSettingAttribute::Anonymous;
} }
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-settings-attribute-credentials-mode
Fetch::Infrastructure::Request::CredentialsMode cors_settings_attribute_credentials_mode(CORSSettingAttribute attribute)
{
switch (attribute) {
// -> No CORS
// -> Anonymous
case CORSSettingAttribute::NoCORS:
case CORSSettingAttribute::Anonymous:
// "same-origin"
return Fetch::Infrastructure::Request::CredentialsMode::SameOrigin;
// -> Use Credentials
case CORSSettingAttribute::UseCredentials:
// "include"
return Fetch::Infrastructure::Request::CredentialsMode::Include;
}
VERIFY_NOT_REACHED();
}
} }

View file

@ -8,6 +8,7 @@
#include <AK/Optional.h> #include <AK/Optional.h>
#include <AK/String.h> #include <AK/String.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
namespace Web::HTML { namespace Web::HTML {
@ -19,5 +20,6 @@ enum class CORSSettingAttribute {
}; };
[[nodiscard]] CORSSettingAttribute cors_setting_attribute_from_keyword(Optional<String> const& keyword); [[nodiscard]] CORSSettingAttribute cors_setting_attribute_from_keyword(Optional<String> const& keyword);
[[nodiscard]] Fetch::Infrastructure::Request::CredentialsMode cors_settings_attribute_credentials_mode(CORSSettingAttribute);
} }