mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:28:12 +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:
parent
53d0ca2ad8
commit
fc5067afd2
4 changed files with 15 additions and 2 deletions
|
@ -86,6 +86,11 @@ void ResourceLoader::load(const URL& url, Function<void(const ByteBuffer&)> succ
|
|||
|
||||
if (url.protocol() == "http") {
|
||||
auto download = protocol_client().start_download(url.to_string());
|
||||
if (!download) {
|
||||
if (error_callback)
|
||||
error_callback("Failed to initiate load");
|
||||
return;
|
||||
}
|
||||
download->on_finish = [this, success_callback = move(success_callback), error_callback = move(error_callback)](bool success, const ByteBuffer& payload, auto) {
|
||||
--m_pending_loads;
|
||||
if (on_load_counter_change)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue