aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/httpclient.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-13 22:30:32 +0100
committerGitHub Enterprise <[email protected]>2026-03-13 22:30:32 +0100
commit162d7412405e78198ede361a8fbae8dc8b82278a (patch)
tree85f91cbbee13ec8fe73b2ba91bfc59d95116d0ef /src/zenhttp/httpclient.cpp
parentAdd clang-cl build support (diff)
downloadzen-162d7412405e78198ede361a8fbae8dc8b82278a.tar.xz
zen-162d7412405e78198ede361a8fbae8dc8b82278a.zip
Made CPR optional, html generated at build time (#840)
- Fix potential crash on startup caused by logging macros being invoked before the logging system is initialized (null logger dereference in `ZenServerState::Sweep()`). `LoggerRef::ShouldLog` now guards against a null logger pointer. - Make CPR an optional dependency (`--zencpr` build option, enabled by default) so builds can proceed without it - Make zenvfs Windows-only (platform-specific target) - Generate the frontend zip at build time from source HTML files instead of checking in a binary blob which would accumulate with every single update
Diffstat (limited to 'src/zenhttp/httpclient.cpp')
-rw-r--r--src/zenhttp/httpclient.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/zenhttp/httpclient.cpp b/src/zenhttp/httpclient.cpp
index deeeb6c85..9f49802a0 100644
--- a/src/zenhttp/httpclient.cpp
+++ b/src/zenhttp/httpclient.cpp
@@ -36,15 +36,17 @@
namespace zen {
+#if ZEN_WITH_CPR
extern HttpClientBase* CreateCprHttpClient(std::string_view BaseUri,
const HttpClientSettings& ConnectionSettings,
std::function<bool()>&& CheckIfAbortFunction);
+#endif
extern HttpClientBase* CreateCurlHttpClient(std::string_view BaseUri,
const HttpClientSettings& ConnectionSettings,
std::function<bool()>&& CheckIfAbortFunction);
-static HttpClientBackend g_DefaultHttpClientBackend = HttpClientBackend::kCpr;
+static HttpClientBackend g_DefaultHttpClientBackend = HttpClientBackend::kCurl;
void
SetDefaultHttpClientBackend(HttpClientBackend Backend)
@@ -55,11 +57,14 @@ SetDefaultHttpClientBackend(HttpClientBackend Backend)
void
SetDefaultHttpClientBackend(std::string_view Backend)
{
+#if ZEN_WITH_CPR
if (Backend == "cpr")
{
g_DefaultHttpClientBackend = HttpClientBackend::kCpr;
}
- else if (Backend == "curl")
+ else
+#endif
+ if (Backend == "curl")
{
g_DefaultHttpClientBackend = HttpClientBackend::kCurl;
}
@@ -363,13 +368,15 @@ HttpClient::HttpClient(std::string_view BaseUri, const HttpClientSettings& Conne
switch (EffectiveBackend)
{
- case HttpClientBackend::kCurl:
- m_Inner = CreateCurlHttpClient(BaseUri, ConnectionSettings, std::move(CheckIfAbortFunction));
- break;
+#if ZEN_WITH_CPR
case HttpClientBackend::kCpr:
- default:
m_Inner = CreateCprHttpClient(BaseUri, ConnectionSettings, std::move(CheckIfAbortFunction));
break;
+#endif
+ case HttpClientBackend::kCurl:
+ default:
+ m_Inner = CreateCurlHttpClient(BaseUri, ConnectionSettings, std::move(CheckIfAbortFunction));
+ break;
}
}