mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 15:44:57 +00:00
ProtocolServer: Support request headers
You can now pass a dictionary of request headers when starting a new download in ProtocolServer. The HTTP and HTTPS protocol will include the headers in their requests.
This commit is contained in:
parent
25cfdf3f67
commit
897998017a
13 changed files with 35 additions and 13 deletions
|
@ -47,9 +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)
|
||||
RefPtr<Download> Client::start_download(const String& url, const HashMap<String, String>& request_headers)
|
||||
{
|
||||
i32 download_id = send_sync<Messages::ProtocolServer::StartDownload>(url)->download_id();
|
||||
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();
|
||||
if (download_id < 0)
|
||||
return nullptr;
|
||||
auto download = Download::create_from_id({}, *this, download_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue