aboutsummaryrefslogtreecommitdiff
path: root/thirdparty/cpr/test/httpsServer.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-27 12:03:02 +0100
committerGitHub Enterprise <[email protected]>2026-03-27 12:03:02 +0100
commitfa3b5090e94ee1386ca6ed6c4ddf886fa46dca54 (patch)
treec574405fc12dd2af9fcb02353df10adb29587f6c /thirdparty/cpr/test/httpsServer.cpp
parentidle deprovision in hub (#895) (diff)
downloadzen-fa3b5090e94ee1386ca6ed6c4ddf886fa46dca54.tar.xz
zen-fa3b5090e94ee1386ca6ed6c4ddf886fa46dca54.zip
remove CPR HTTP client backend (#894)
CPR is no longer needed now that HttpClient has fully transitioned to raw libcurl. This removes the CPR library, its build integration, implementation files, and all conditional compilation guards, leaving curl as the sole HTTP client backend.
Diffstat (limited to 'thirdparty/cpr/test/httpsServer.cpp')
-rw-r--r--thirdparty/cpr/test/httpsServer.cpp65
1 files changed, 0 insertions, 65 deletions
diff --git a/thirdparty/cpr/test/httpsServer.cpp b/thirdparty/cpr/test/httpsServer.cpp
deleted file mode 100644
index 401a47032..000000000
--- a/thirdparty/cpr/test/httpsServer.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-#include "httpsServer.hpp"
-#include <system_error>
-
-namespace cpr {
-HttpsServer::HttpsServer(fs::path&& baseDirPath, fs::path&& sslCertFileName, fs::path&& sslKeyFileName) : baseDirPath(baseDirPath.make_preferred().string()), sslCertFileName(sslCertFileName.make_preferred().string()), sslKeyFileName(sslKeyFileName.make_preferred().string()) {
- // See https://mongoose.ws/tutorials/tls/
- memset(static_cast<void*>(&tlsOpts), 0, sizeof(tlsOpts));
- tlsOpts.cert = this->sslCertFileName.c_str();
- tlsOpts.certkey = this->sslKeyFileName.c_str();
-}
-
-std::string HttpsServer::GetBaseUrl() {
- return "https://127.0.0.1:" + std::to_string(GetPort());
-}
-
-uint16_t HttpsServer::GetPort() {
- // Unassigned port in the ephemeral range
- return 61937;
-}
-
-mg_connection* HttpsServer::initServer(mg_mgr* mgr, mg_event_handler_t event_handler) {
- mg_mgr_init(mgr);
-
- std::string port = std::to_string(GetPort());
- mg_connection* c = mg_http_listen(mgr, GetBaseUrl().c_str(), event_handler, this);
- return c;
-}
-
-void HttpsServer::acceptConnection(mg_connection* conn) {
- // See https://mongoose.ws/tutorials/tls/
- mg_tls_init(conn, &tlsOpts);
-}
-
-void HttpsServer::OnRequest(mg_connection* conn, mg_http_message* msg) {
- std::string uri = std::string(msg->uri.ptr, msg->uri.len);
- if (uri == "/hello.html") {
- OnRequestHello(conn, msg);
- } else {
- OnRequestNotFound(conn, msg);
- }
-}
-
-void HttpsServer::OnRequestNotFound(mg_connection* conn, mg_http_message* /*msg*/) {
- mg_http_reply(conn, 404, nullptr, "Not Found");
-}
-
-void HttpsServer::OnRequestHello(mg_connection* conn, mg_http_message* /*msg*/) {
- std::string response{"Hello world!"};
- std::string headers{"Content-Type: text/html\r\n"};
- mg_http_reply(conn, 200, headers.c_str(), response.c_str());
-}
-
-const std::string& HttpsServer::getBaseDirPath() const {
- return baseDirPath;
-}
-
-const std::string& HttpsServer::getSslCertFileName() const {
- return sslCertFileName;
-}
-
-const std::string& HttpsServer::getSslKeyFileName() const {
- return sslKeyFileName;
-}
-
-} // namespace cpr