1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

ProtocolServer+LibProtocol: Reject unhandled URLs instead of asserting

StartDownload requests for unhandled protocols (or invalid URLs) will
now refuse to load instead of asserting. A failure code is sent back
to LibProtocol and Protocol::Client::start_download() returns nullptr.

Fixes #1604.
This commit is contained in:
Andreas Kling 2020-04-04 20:00:07 +02:00
parent 53d0ca2ad8
commit fc5067afd2
4 changed files with 15 additions and 2 deletions

View file

@ -50,6 +50,8 @@ bool Client::is_supported_protocol(const String& protocol)
RefPtr<Download> Client::start_download(const String& url)
{
i32 download_id = send_sync<Messages::ProtocolServer::StartDownload>(url)->download_id();
if (download_id < 0)
return nullptr;
auto download = Download::create_from_id({}, *this, download_id);
m_downloads.set(download_id, download);
return download;