diff --git a/Userland/Libraries/LibCore/NetworkJob.cpp b/Userland/Libraries/LibCore/NetworkJob.cpp index dd8b15ed00..c79f3085b4 100644 --- a/Userland/Libraries/LibCore/NetworkJob.cpp +++ b/Userland/Libraries/LibCore/NetworkJob.cpp @@ -29,6 +29,9 @@ void NetworkJob::shutdown() void NetworkJob::did_finish(NonnullRefPtr&& response) { + if (is_cancelled()) + return; + // NOTE: We protect ourselves here, since the on_finish callback may otherwise // trigger destruction of this job somehow. NonnullRefPtr protector(*this); @@ -42,6 +45,9 @@ void NetworkJob::did_finish(NonnullRefPtr&& response) void NetworkJob::did_fail(Error error) { + if (is_cancelled()) + return; + // NOTE: We protect ourselves here, since the on_finish callback may otherwise // trigger destruction of this job somehow. NonnullRefPtr protector(*this); @@ -55,6 +61,9 @@ void NetworkJob::did_fail(Error error) void NetworkJob::did_progress(Optional total_size, u32 downloaded) { + if (is_cancelled()) + return; + // NOTE: We protect ourselves here, since the callback may otherwise // trigger destruction of this job somehow. NonnullRefPtr protector(*this); diff --git a/Userland/Services/RequestServer/GeminiRequest.cpp b/Userland/Services/RequestServer/GeminiRequest.cpp index d98feb0546..9b087d783b 100644 --- a/Userland/Services/RequestServer/GeminiRequest.cpp +++ b/Userland/Services/RequestServer/GeminiRequest.cpp @@ -58,7 +58,7 @@ GeminiRequest::~GeminiRequest() { m_job->on_finish = nullptr; m_job->on_progress = nullptr; - m_job->shutdown(); + m_job->cancel(); } NonnullOwnPtr GeminiRequest::create_with_job(Badge, ClientConnection& client, NonnullRefPtr job, NonnullOwnPtr&& output_stream) diff --git a/Userland/Services/RequestServer/HttpRequest.cpp b/Userland/Services/RequestServer/HttpRequest.cpp index 0a13a520ca..a0f29f2e3c 100644 --- a/Userland/Services/RequestServer/HttpRequest.cpp +++ b/Userland/Services/RequestServer/HttpRequest.cpp @@ -22,7 +22,7 @@ HttpRequest::~HttpRequest() { m_job->on_finish = nullptr; m_job->on_progress = nullptr; - m_job->shutdown(); + m_job->cancel(); } NonnullOwnPtr HttpRequest::create_with_job(Badge&&, ClientConnection& client, NonnullRefPtr job, NonnullOwnPtr&& output_stream) diff --git a/Userland/Services/RequestServer/HttpsRequest.cpp b/Userland/Services/RequestServer/HttpsRequest.cpp index 95c78157ba..f3f537705c 100644 --- a/Userland/Services/RequestServer/HttpsRequest.cpp +++ b/Userland/Services/RequestServer/HttpsRequest.cpp @@ -27,7 +27,7 @@ HttpsRequest::~HttpsRequest() { m_job->on_finish = nullptr; m_job->on_progress = nullptr; - m_job->shutdown(); + m_job->cancel(); } NonnullOwnPtr HttpsRequest::create_with_job(Badge&&, ClientConnection& client, NonnullRefPtr job, NonnullOwnPtr&& output_stream)