LibWeb: Implement formData() method steps for x-www-form-urlencoded

The Response interface of the Fetch API can now parse form urlencoded
bodies when Content-Type is set to 'application/x-www-form-urlencoded'.
This commit is contained in:
Kenneth Myhra 2024-07-22 13:49:07 +02:00 committed by Andreas Kling
commit b8fa572c67
Notes: github-actions[bot] 2024-07-23 07:03:35 +00:00
5 changed files with 46 additions and 6 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Kenneth Myhra <kennethmyhra@serenityos.org>
* Copyright (c) 2023-2024, Kenneth Myhra <kennethmyhra@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -40,6 +40,16 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<FormData>> FormData::construct_impl(JS::Rea
return realm.heap().allocate<FormData>(realm, realm, move(entry_list));
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<FormData>> FormData::create(JS::Realm& realm, Vector<DOMURL::QueryParam> entry_list)
{
Vector<FormDataEntry> list;
list.ensure_capacity(entry_list.size());
for (auto& entry : entry_list)
list.unchecked_append({ .name = move(entry.name), .value = move(entry.value) });
return construct_impl(realm, move(list));
}
FormData::FormData(JS::Realm& realm, Vector<FormDataEntry> entry_list)
: PlatformObject(realm)
, m_entry_list(move(entry_list))