ProtocolServer+LibWeb: Support more detailed HTTP requests

This patch adds the ability for ProtocolServer clients to specify which
HTTP method to use, and also to include an optional HTTP request body.
This commit is contained in:
Andreas Kling 2020-09-28 11:55:26 +02:00
commit 2946a684ef
Notes: sideshowbarker 2024-07-19 02:09:01 +09:00
21 changed files with 78 additions and 26 deletions

View file

@ -47,13 +47,13 @@ bool Client::is_supported_protocol(const String& protocol)
return send_sync<Messages::ProtocolServer::IsSupportedProtocol>(protocol)->supported();
}
RefPtr<Download> Client::start_download(const String& url, const HashMap<String, String>& request_headers)
RefPtr<Download> Client::start_download(const String& method, const String& url, const HashMap<String, String>& request_headers, const ByteBuffer& request_body)
{
IPC::Dictionary header_dictionary;
for (auto& it : request_headers)
header_dictionary.add(it.key, it.value);
i32 download_id = send_sync<Messages::ProtocolServer::StartDownload>(url, header_dictionary)->download_id();
i32 download_id = send_sync<Messages::ProtocolServer::StartDownload>(method, url, header_dictionary, String::copy(request_body))->download_id();
if (download_id < 0)
return nullptr;
auto download = Download::create_from_id({}, *this, download_id);