1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 16:17:45 +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 @@
#pragma once
#include <AK/Badge.h>
#include <AK/NonnullOwnPtr.h>
#include <LibCore/Forward.h>
#include <LibHTTP/Forward.h>
#include <ProtocolServer/Download.h>
@ -36,7 +37,7 @@ namespace ProtocolServer {
class HttpDownload final : public Download {
public:
virtual ~HttpDownload() override;
static NonnullOwnPtr<HttpDownload> create_with_job(Badge<HttpProtocol>, ClientConnection&, NonnullRefPtr<HTTP::HttpJob>, NonnullOwnPtr<OutputFileStream>&&);
static NonnullOwnPtr<HttpDownload> create_with_job(Badge<HttpProtocol>&&, ClientConnection&, NonnullRefPtr<HTTP::HttpJob>, NonnullOwnPtr<OutputFileStream>&&);
private:
explicit HttpDownload(ClientConnection&, NonnullRefPtr<HTTP::HttpJob>, NonnullOwnPtr<OutputFileStream>&&);