1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

LibWeb+LibHTTP: Support multiple Set-Cookie response headers

This commit is contained in:
TheFightingCatfish 2021-08-11 06:09:35 +08:00 committed by Ali Mohammad Pur
parent 0e873464ed
commit 57541f433b
3 changed files with 29 additions and 5 deletions

View file

@ -5,6 +5,7 @@
*/
#include <AK/Debug.h>
#include <AK/JsonArray.h>
#include <AK/LexicalPath.h>
#include <AK/SourceGenerator.h>
#include <LibGemini/Document.h>
@ -294,10 +295,15 @@ void FrameLoader::resource_did_load()
return;
}
// FIXME: Support multiple instances of the Set-Cookie response header.
auto set_cookie = resource()->response_headers().get("Set-Cookie");
if (set_cookie.has_value())
document->set_cookie(set_cookie.value(), Cookie::Source::Http);
if (set_cookie.has_value()) {
auto set_cookie_json_value = MUST(JsonValue::from_string(set_cookie.value()));
VERIFY(set_cookie_json_value.type() == JsonValue::Type::Array);
for (const auto& set_cookie_entry : set_cookie_json_value.as_array().values()) {
VERIFY(set_cookie_entry.type() == JsonValue::Type::String);
document->set_cookie(set_cookie_entry.as_string(), Cookie::Source::Http);
}
}
if (!url.fragment().is_empty())
browsing_context().scroll_to_anchor(url.fragment());