mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:58:12 +00:00
LibWeb: Set method, headers and Content-Length in BC navigation
This is all ad-hoc, but will disappear when we switch to navigables.
This commit is contained in:
parent
eaa4048870
commit
bd62fe9c33
1 changed files with 15 additions and 1 deletions
|
@ -1220,7 +1220,21 @@ WebIDL::ExceptionOr<void> BrowsingContext::navigate(
|
|||
(void)process_response_end_of_body;
|
||||
|
||||
// AD-HOC:
|
||||
loader().load(resource->url(), FrameLoader::Type::IFrame);
|
||||
auto request = LoadRequest::create_for_url_on_page(resource->url(), page());
|
||||
request.set_method(DeprecatedString { resource->method() });
|
||||
for (auto& header : *resource->header_list()) {
|
||||
request.set_header(DeprecatedString { header.name.bytes() }, DeprecatedString { header.value.bytes() });
|
||||
}
|
||||
if (request.method() == "POST"sv) {
|
||||
if (resource->body().has<ByteBuffer>()) {
|
||||
auto const& byte_buffer = resource->body().get<ByteBuffer>();
|
||||
request.set_body(byte_buffer);
|
||||
request.set_header("Content-Length", DeprecatedString::number(byte_buffer.size()));
|
||||
} else {
|
||||
request.set_header("Content-Length", DeprecatedString::number(0));
|
||||
}
|
||||
}
|
||||
loader().load(request, FrameLoader::Type::Navigation);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue