aboutsummaryrefslogtreecommitdiff
path: root/zencore/httpsys.h
diff options
context:
space:
mode:
Diffstat (limited to 'zencore/httpsys.h')
-rw-r--r--zencore/httpsys.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/zencore/httpsys.h b/zencore/httpsys.h
new file mode 100644
index 000000000..8a7b372dd
--- /dev/null
+++ b/zencore/httpsys.h
@@ -0,0 +1,58 @@
+#pragma once
+
+#include <zencore/httpserver.h>
+
+#define _WINSOCKAPI_
+#include <zencore/windows.h>
+#include "iothreadpool.h"
+
+#include <atlbase.h>
+#include <http.h>
+
+namespace zen {
+
+/**
+ * @brief Windows implementation of HTTP server based on http.sys
+ *
+ * This requires elevation to function
+ */
+class HttpSysServer
+{
+ friend class HttpSysTransaction;
+
+public:
+ HttpSysServer(WinIoThreadPool& InThreadPool);
+ ~HttpSysServer();
+
+ void Initialize(const wchar_t* UrlPath);
+ void Run(bool TestMode);
+
+ void RequestExit() { m_ShutdownEvent.Set(); }
+
+ void StartServer();
+ void StopServer();
+
+ void OnHandlingRequest();
+ void IssueNewRequestMaybe();
+
+ inline bool IsOk() const { return m_IsOk; }
+
+ void AddEndpoint(const char* Endpoint, HttpService& Service);
+ void RemoveEndpoint(const char* Endpoint, HttpService& Service);
+
+private:
+ bool m_IsOk = false;
+ bool m_IsHttpInitialized = false;
+ WinIoThreadPool& m_ThreadPool;
+
+ std::wstring m_BaseUri; // http://*:nnnn/
+ HTTP_SERVER_SESSION_ID m_HttpSessionId = 0;
+ HTTP_URL_GROUP_ID m_HttpUrlGroupId = 0;
+ HANDLE m_RequestQueueHandle = 0;
+ std::atomic_int32_t m_PendingRequests{0};
+ int32_t m_MinPendingRequests = 4;
+ int32_t m_MaxPendingRequests = 32;
+ Event m_ShutdownEvent;
+};
+
+}