diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/external_dependencies/cpr/test/httpsServer.hpp | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/external_dependencies/cpr/test/httpsServer.hpp')
-rw-r--r-- | Src/external_dependencies/cpr/test/httpsServer.hpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Src/external_dependencies/cpr/test/httpsServer.hpp b/Src/external_dependencies/cpr/test/httpsServer.hpp new file mode 100644 index 00000000..cea4d343 --- /dev/null +++ b/Src/external_dependencies/cpr/test/httpsServer.hpp @@ -0,0 +1,42 @@ +#ifndef CPR_TEST_HTTPS_SERVER_H +#define CPR_TEST_HTTPS_SERVER_H + +#include <memory> +#include <string> + +#include "abstractServer.hpp" +#include "cpr/cpr.h" +#include "mongoose.h" +#include <cpr/filesystem.h> + +namespace cpr { +class HttpsServer : public AbstractServer { + private: + // We don't use fs::path here, as this leads to problems using windows + const std::string baseDirPath; + const std::string sslCertFileName; + const std::string sslKeyFileName; + struct mg_tls_opts tlsOpts; + + public: + explicit HttpsServer(fs::path&& baseDirPath, fs::path&& sslCertFileName, fs::path&& sslKeyFileName); + ~HttpsServer() override = default; + + std::string GetBaseUrl() override; + uint16_t GetPort() override; + + void OnRequest(mg_connection* conn, mg_http_message* msg) override; + static void OnRequestHello(mg_connection* conn, mg_http_message* msg); + static void OnRequestNotFound(mg_connection* conn, mg_http_message* msg); + + const std::string& getBaseDirPath() const; + const std::string& getSslCertFileName() const; + const std::string& getSslKeyFileName() const; + + protected: + mg_connection* initServer(mg_mgr* mgr, mg_event_handler_t event_handler) override; + void acceptConnection(mg_connection* conn) override; +}; +} // namespace cpr + +#endif |