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

Http[s]Protocol: Make the code start_download DRY

Problem:
- `HttpProtocol::start_download` and `HttpsProtocol::start_download`
  implementations are the same except for a few types.

Solution:
- Follow the "Don't Repeat Yourself" mantra and de-duplicate the code
  using templates.
This commit is contained in:
Lenny Maiorani 2021-01-14 10:07:10 -07:00 committed by Andreas Kling
parent 6d6b3f9523
commit 7e71de8f1f
9 changed files with 120 additions and 56 deletions

View file

@ -27,6 +27,7 @@
#include <LibHTTP/HttpResponse.h>
#include <LibHTTP/HttpsJob.h>
#include <ProtocolServer/HttpsDownload.h>
#include <ProtocolServer/HttpsProtocol.h>
namespace ProtocolServer {
@ -74,7 +75,7 @@ HttpsDownload::~HttpsDownload()
m_job->shutdown();
}
NonnullOwnPtr<HttpsDownload> HttpsDownload::create_with_job(Badge<HttpsProtocol>, ClientConnection& client, NonnullRefPtr<HTTP::HttpsJob> job, NonnullOwnPtr<OutputFileStream>&& output_stream)
NonnullOwnPtr<HttpsDownload> HttpsDownload::create_with_job(Badge<HttpsProtocol>&&, ClientConnection& client, NonnullRefPtr<HTTP::HttpsJob> job, NonnullOwnPtr<OutputFileStream>&& output_stream)
{
return adopt_own(*new HttpsDownload(client, move(job), move(output_stream)));
}