1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-24 03:45:07 +00:00

ProtocolServer: Implement and handle download progress

Also updates `pro` to display download progress and speed on stderr
This commit is contained in:
AnotherTest 2020-05-03 09:01:06 +04:30 committed by Andreas Kling
parent c6825a96c7
commit 06cf9d3fb7
14 changed files with 97 additions and 22 deletions

View file

@ -35,8 +35,17 @@ HttpDownload::HttpDownload(PSClientConnection& client, NonnullRefPtr<HTTP::HttpJ
m_job->on_finish = [this](bool success) {
if (m_job->response())
set_payload(m_job->response()->payload());
// if we didn't know the total size, pretend that the download finished successfully
// and set the total size to the downloaded size
if (!total_size().has_value())
did_progress(downloaded_size(), downloaded_size());
did_finish(success);
};
m_job->on_progress = [this](Optional<u32> total, u32 current) {
did_progress(total, current);
};
}
HttpDownload::~HttpDownload()