LibWeb: Properly copy method and headers from the input in Request()

We were accidentally copying these from the newly created Request
object's underlying request, to itself. Thanks to Lubrsi for catching
this!

Co-authored-by: Luke Wilde <lukew@serenityos.org>
This commit is contained in:
Linus Groh 2022-11-04 21:20:46 +00:00
parent 71228a8d86
commit 6cd57d4c15
Notes: sideshowbarker 2024-07-17 04:47:24 +09:00

View file

@ -174,12 +174,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
// method
// requests method.
request->set_method(TRY_OR_RETURN_OOM(realm, ByteBuffer::copy(request->method())));
request->set_method(TRY_OR_RETURN_OOM(realm, ByteBuffer::copy(input_request->method())));
// header list
// A copy of requests header list.
auto header_list_copy = Infrastructure::HeaderList::create(vm);
for (auto& header : *request->header_list())
for (auto& header : *input_request->header_list())
TRY_OR_RETURN_OOM(realm, header_list_copy->append(header));
request->set_header_list(header_list_copy);