1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:07:34 +00:00

ProtocolServer: Add some debug log output for failed downloads

To make it easier to work out what went wrong.
This commit is contained in:
Andreas Kling 2021-01-03 13:10:53 +01:00
parent 7be2c9864e
commit 3e8050f002

View file

@ -60,15 +60,21 @@ OwnPtr<Messages::ProtocolServer::IsSupportedProtocolResponse> ClientConnection::
OwnPtr<Messages::ProtocolServer::StartDownloadResponse> ClientConnection::handle(const Messages::ProtocolServer::StartDownload& message) OwnPtr<Messages::ProtocolServer::StartDownloadResponse> ClientConnection::handle(const Messages::ProtocolServer::StartDownload& message)
{ {
URL url(message.url()); const auto& url = message.url();
if (!url.is_valid()) if (!url.is_valid()) {
dbgln("StartDownload: Invalid URL requested: '{}'", url);
return make<Messages::ProtocolServer::StartDownloadResponse>(-1, Optional<IPC::File> {}); return make<Messages::ProtocolServer::StartDownloadResponse>(-1, Optional<IPC::File> {});
}
auto* protocol = Protocol::find_by_name(url.protocol()); 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> {}); 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()); 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> {}); return make<Messages::ProtocolServer::StartDownloadResponse>(-1, Optional<IPC::File> {});
}
auto id = download->id(); auto id = download->id();
auto fd = download->download_fd(); auto fd = download->download_fd();
m_downloads.set(id, move(download)); m_downloads.set(id, move(download));