mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 09:46:04 -05:00
fd4349a9f2
This patch adds ProtocolServer, a server that handles network requests on behalf of its clients. The first protocol implemented is HTTP. The idea here is to use a plug-in architecture where any number of protocols can be added and implemented without having to mess around with each client program that wants to use the protocol. A simple client API is provided through LibProtocol::Client. :^)
24 lines
580 B
C++
24 lines
580 B
C++
#include <LibCore/CHttpJob.h>
|
|
#include <LibCore/CHttpRequest.h>
|
|
#include <ProtocolServer/HttpDownload.h>
|
|
#include <ProtocolServer/HttpProtocol.h>
|
|
|
|
HttpProtocol::HttpProtocol()
|
|
: Protocol("http")
|
|
{
|
|
}
|
|
|
|
HttpProtocol::~HttpProtocol()
|
|
{
|
|
}
|
|
|
|
RefPtr<Download> HttpProtocol::start_download(PSClientConnection& client, const URL& url)
|
|
{
|
|
CHttpRequest request;
|
|
request.set_method(CHttpRequest::Method::GET);
|
|
request.set_url(url);
|
|
auto job = request.schedule();
|
|
if (!job)
|
|
return nullptr;
|
|
return HttpDownload::create_with_job({}, client, (CHttpJob&)*job);
|
|
}
|