diff options
| author | Stefan Boberg <[email protected]> | 2021-09-09 13:37:15 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-09 13:37:15 +0200 |
| commit | f8ca66bd0de36de9a29a409b0e527cede19ef91c (patch) | |
| tree | 3c72f457c57d97eef13650be865faa2ac7e8f202 /zencore/httpsys.h | |
| parent | Merge branch 'main' into cbpackage-update (diff) | |
| download | zen-f8ca66bd0de36de9a29a409b0e527cede19ef91c.tar.xz zen-f8ca66bd0de36de9a29a409b0e527cede19ef91c.zip | |
Moved http.sys server implementation into dedicated source files
Diffstat (limited to 'zencore/httpsys.h')
| -rw-r--r-- | zencore/httpsys.h | 58 |
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; +}; + +} |