1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:57: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

@ -26,14 +26,26 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <AK/String.h>
#include <AK/URL.h>
#include <LibHTTP/HttpJob.h>
#include <ProtocolServer/ClientConnection.h>
#include <ProtocolServer/Download.h>
#include <ProtocolServer/HttpDownload.h>
#include <ProtocolServer/Protocol.h>
namespace ProtocolServer {
class HttpProtocol final : public Protocol {
public:
using JobType = HTTP::HttpJob;
using DownloadType = HttpDownload;
HttpProtocol();
virtual ~HttpProtocol() override;
~HttpProtocol() override = default;
virtual OwnPtr<Download> start_download(ClientConnection&, const String& method, const URL&, const HashMap<String, String>& headers, ReadonlyBytes body) override;
};