mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 14:05:15 +00:00
The CNetworkJob::on_finish hook will be invoked both for success and failure, but there will only be a m_job->response() in the success case so we have to null-check it before using it. This should have been obvious from the "->"
23 lines
639 B
C++
23 lines
639 B
C++
#include <LibCore/CHttpJob.h>
|
|
#include <LibCore/CHttpResponse.h>
|
|
#include <ProtocolServer/HttpDownload.h>
|
|
|
|
HttpDownload::HttpDownload(PSClientConnection& client, NonnullRefPtr<CHttpJob>&& job)
|
|
: Download(client)
|
|
, m_job(job)
|
|
{
|
|
m_job->on_finish = [this](bool success) {
|
|
if (m_job->response())
|
|
set_payload(m_job->response()->payload());
|
|
did_finish(success);
|
|
};
|
|
}
|
|
|
|
HttpDownload::~HttpDownload()
|
|
{
|
|
}
|
|
|
|
NonnullRefPtr<HttpDownload> HttpDownload::create_with_job(Badge<HttpProtocol>, PSClientConnection& client, NonnullRefPtr<CHttpJob>&& job)
|
|
{
|
|
return adopt(*new HttpDownload(client, move(job)));
|
|
}
|