mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-14 21:28:40 +03: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
424 B
C++
24 lines
424 B
C++
#include <AK/HashMap.h>
|
|
#include <ProtocolServer/Protocol.h>
|
|
|
|
static HashMap<String, Protocol*>& all_protocols()
|
|
{
|
|
static HashMap<String, Protocol*> map;
|
|
return map;
|
|
}
|
|
|
|
Protocol* Protocol::find_by_name(const String& name)
|
|
{
|
|
return all_protocols().get(name).value_or(nullptr);
|
|
}
|
|
|
|
Protocol::Protocol(const String& name)
|
|
{
|
|
all_protocols().set(name, this);
|
|
}
|
|
|
|
Protocol::~Protocol()
|
|
{
|
|
ASSERT_NOT_REACHED();
|
|
}
|