aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/httpserver.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-10-10 13:30:07 +0200
committerGitHub <[email protected]>2023-10-10 13:30:07 +0200
commit7905d0d21af95c6016768d7a8a81dd9204b34d24 (patch)
tree076329f5fad1c33503ee611f6399853da2490567 /src/zenhttp/httpserver.cpp
parentcache reference tracking (#455) (diff)
downloadzen-7905d0d21af95c6016768d7a8a81dd9204b34d24.tar.xz
zen-7905d0d21af95c6016768d7a8a81dd9204b34d24.zip
experimental pluggable transport support (#436)
this change adds a `--http=plugin` mode where we support pluggable transports. Currently this defaults to a barebones blocking winsock implementation but there is also support for dynamic loading of transport plugins, which will be further developed in the near future.
Diffstat (limited to 'src/zenhttp/httpserver.cpp')
-rw-r--r--src/zenhttp/httpserver.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/zenhttp/httpserver.cpp b/src/zenhttp/httpserver.cpp
index a98a3c9bb..523befa72 100644
--- a/src/zenhttp/httpserver.cpp
+++ b/src/zenhttp/httpserver.cpp
@@ -6,6 +6,13 @@
#include "httpnull.h"
#include "httpsys.h"
+#include "zenhttp/httpplugin.h"
+
+#if ZEN_WITH_PLUGINS
+# include "dlltransport.h"
+# include "winsocktransport.h"
+#endif
+
#include <zencore/compactbinary.h>
#include <zencore/compactbinarybuilder.h>
#include <zencore/compactbinarypackage.h>
@@ -711,6 +718,7 @@ enum class HttpServerClass
{
kHttpAsio,
kHttpSys,
+ kHttpPlugin,
kHttpNull
};
@@ -723,7 +731,7 @@ CreateHttpServer(const HttpServerConfig& Config)
#if ZEN_WITH_HTTPSYS
Class = HttpServerClass::kHttpSys;
-#elif 1
+#else
Class = HttpServerClass::kHttpAsio;
#endif
@@ -735,6 +743,10 @@ CreateHttpServer(const HttpServerConfig& Config)
{
Class = HttpServerClass::kHttpSys;
}
+ else if (Config.ServerClass == "plugin"sv)
+ {
+ Class = HttpServerClass::kHttpPlugin;
+ }
else if (Config.ServerClass == "null"sv)
{
Class = HttpServerClass::kHttpNull;
@@ -747,6 +759,27 @@ CreateHttpServer(const HttpServerConfig& Config)
ZEN_INFO("using asio HTTP server implementation");
return Ref<HttpServer>(new HttpAsioServer(Config.ThreadCount));
+#if ZEN_WITH_PLUGINS
+ case HttpServerClass::kHttpPlugin:
+ {
+ ZEN_INFO("using plugin HTTP server implementation");
+ Ref<HttpPluginServer> Server{new HttpPluginServer(Config.ThreadCount)};
+
+# if 1
+ Ref<TransportPluginInterface> WinsockPlugin{CreateSocketTransportPlugin(1337, Config.ThreadCount)};
+ Server->AddPlugin(WinsockPlugin);
+# endif
+
+# if 0
+ Ref<DllTransportPlugin> DllPlugin{new DllTransportPlugin(1337, Config.ThreadCount)};
+ DllPlugin->LoadDll("winsock");
+ Server->AddPlugin(DllPlugin);
+# endif
+
+ return Server;
+ }
+#endif
+
#if ZEN_WITH_HTTPSYS
case HttpServerClass::kHttpSys:
ZEN_INFO("using http.sys server implementation");