Skip to content

Commit

Permalink
ProtocolServer: Add some debug log output for failed downloads
Browse files Browse the repository at this point in the history
To make it easier to work out what went wrong.
  • Loading branch information
awesomekling committed Jan 3, 2021
1 parent 7be2c98 commit 3e8050f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Services/ProtocolServer/ClientConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,21 @@ OwnPtr<Messages::ProtocolServer::IsSupportedProtocolResponse> ClientConnection::

OwnPtr<Messages::ProtocolServer::StartDownloadResponse> ClientConnection::handle(const Messages::ProtocolServer::StartDownload& message)
{
URL url(message.url());
if (!url.is_valid())
const auto& url = message.url();
if (!url.is_valid()) {
dbgln("StartDownload: Invalid URL requested: '{}'", url);
return make<Messages::ProtocolServer::StartDownloadResponse>(-1, Optional<IPC::File> {});
}
auto* protocol = Protocol::find_by_name(url.protocol());
if (!protocol)
if (!protocol) {
dbgln("StartDownload: No protocol handler for URL: '{}'", url);
return make<Messages::ProtocolServer::StartDownloadResponse>(-1, Optional<IPC::File> {});
}
auto download = protocol->start_download(*this, message.method(), url, message.request_headers().entries(), message.request_body());
if (!download)
if (!download) {
dbgln("StartDownload: Protocol handler failed to start download: '{}'", url);
return make<Messages::ProtocolServer::StartDownloadResponse>(-1, Optional<IPC::File> {});
}
auto id = download->id();
auto fd = download->download_fd();
m_downloads.set(id, move(download));
Expand Down

0 comments on commit 3e8050f

Please sign in to comment.