aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2026-03-27 09:51:29 +0100
committerGitHub Enterprise <[email protected]>2026-03-27 09:51:29 +0100
commite811745e5c37dd38a8fb9f4bc2892525401eabbd (patch)
tree63896cabc0eb895887dc8247bb573f0dfd696afa /src/zenhttp
parenthub async provision/deprovision/hibernate/wake (#891) (diff)
downloadzen-e811745e5c37dd38a8fb9f4bc2892525401eabbd.tar.xz
zen-e811745e5c37dd38a8fb9f4bc2892525401eabbd.zip
hub instance state refactor (#892)
- Improvement: Provisioning a hibernated instance now automatically wakes it instead of requiring an explicit wake call first - Improvement: Deprovisioning now accepts instances in Crashed or Hibernated states, not just Provisioned - Improvement: Added `--consul-health-interval-seconds` and `--consul-deregister-after-seconds` options to control Consul health check behavior (defaults: 10s and 30s) - Improvement: Consul registration now occurs when provisioning starts; health check intervals are applied once provisioning completes
Diffstat (limited to 'src/zenhttp')
-rw-r--r--src/zenhttp/clients/httpclientcommon.h5
-rw-r--r--src/zenhttp/clients/httpclientcpr.cpp4
-rw-r--r--src/zenhttp/clients/httpclientcpr.h5
-rw-r--r--src/zenhttp/clients/httpclientcurl.cpp4
-rw-r--r--src/zenhttp/clients/httpclientcurl.h5
-rw-r--r--src/zenhttp/httpclient.cpp7
-rw-r--r--src/zenhttp/httpclient_test.cpp11
-rw-r--r--src/zenhttp/include/zenhttp/httpclient.h5
8 files changed, 36 insertions, 10 deletions
diff --git a/src/zenhttp/clients/httpclientcommon.h b/src/zenhttp/clients/httpclientcommon.h
index e8d969cc8..c30edab33 100644
--- a/src/zenhttp/clients/httpclientcommon.h
+++ b/src/zenhttp/clients/httpclientcommon.h
@@ -21,7 +21,10 @@ public:
using Response = HttpClient::Response;
using KeyValueMap = HttpClient::KeyValueMap;
- [[nodiscard]] virtual Response Put(std::string_view Url, const IoBuffer& Payload, const KeyValueMap& AdditionalHeader = {}) = 0;
+ [[nodiscard]] virtual Response Put(std::string_view Url,
+ const IoBuffer& Payload,
+ const KeyValueMap& AdditionalHeader = {},
+ const KeyValueMap& Parameters = {}) = 0;
[[nodiscard]] virtual Response Put(std::string_view Url, const KeyValueMap& Parameters = {}) = 0;
[[nodiscard]] virtual Response Get(std::string_view Url,
const KeyValueMap& AdditionalHeader = {},
diff --git a/src/zenhttp/clients/httpclientcpr.cpp b/src/zenhttp/clients/httpclientcpr.cpp
index bd6de3ff7..08e3a8c49 100644
--- a/src/zenhttp/clients/httpclientcpr.cpp
+++ b/src/zenhttp/clients/httpclientcpr.cpp
@@ -653,7 +653,7 @@ CprHttpClient::TransactPackage(std::string_view Url, CbPackage Package, const Ke
//
CprHttpClient::Response
-CprHttpClient::Put(std::string_view Url, const IoBuffer& Payload, const KeyValueMap& AdditionalHeader)
+CprHttpClient::Put(std::string_view Url, const IoBuffer& Payload, const KeyValueMap& AdditionalHeader, const KeyValueMap& Parameters)
{
ZEN_TRACE_CPU("CprHttpClient::Put");
@@ -662,7 +662,7 @@ CprHttpClient::Put(std::string_view Url, const IoBuffer& Payload, const KeyValue
DoWithRetry(m_SessionId,
[&]() {
Session Sess =
- AllocSession(m_BaseUri, Url, m_ConnectionSettings, AdditionalHeader, {}, m_SessionId, GetAccessToken());
+ AllocSession(m_BaseUri, Url, m_ConnectionSettings, AdditionalHeader, Parameters, m_SessionId, GetAccessToken());
Sess->SetBody(AsCprBody(Payload));
Sess->UpdateHeader({HeaderContentType(Payload.GetContentType())});
return Sess.Put();
diff --git a/src/zenhttp/clients/httpclientcpr.h b/src/zenhttp/clients/httpclientcpr.h
index 509ca5ae2..451f22eae 100644
--- a/src/zenhttp/clients/httpclientcpr.h
+++ b/src/zenhttp/clients/httpclientcpr.h
@@ -23,7 +23,10 @@ public:
// HttpClientBase
- [[nodiscard]] virtual Response Put(std::string_view Url, const IoBuffer& Payload, const KeyValueMap& AdditionalHeader = {}) override;
+ [[nodiscard]] virtual Response Put(std::string_view Url,
+ const IoBuffer& Payload,
+ const KeyValueMap& AdditionalHeader = {},
+ const KeyValueMap& Parameters = {}) override;
[[nodiscard]] virtual Response Put(std::string_view Url, const KeyValueMap& Parameters = {}) override;
[[nodiscard]] virtual Response Get(std::string_view Url,
const KeyValueMap& AdditionalHeader = {},
diff --git a/src/zenhttp/clients/httpclientcurl.cpp b/src/zenhttp/clients/httpclientcurl.cpp
index e76157254..d150b44c6 100644
--- a/src/zenhttp/clients/httpclientcurl.cpp
+++ b/src/zenhttp/clients/httpclientcurl.cpp
@@ -980,7 +980,7 @@ CurlHttpClient::TransactPackage(std::string_view Url, CbPackage Package, const K
//
CurlHttpClient::Response
-CurlHttpClient::Put(std::string_view Url, const IoBuffer& Payload, const KeyValueMap& AdditionalHeader)
+CurlHttpClient::Put(std::string_view Url, const IoBuffer& Payload, const KeyValueMap& AdditionalHeader, const KeyValueMap& Parameters)
{
ZEN_TRACE_CPU("CurlHttpClient::Put");
@@ -989,7 +989,7 @@ CurlHttpClient::Put(std::string_view Url, const IoBuffer& Payload, const KeyValu
DoWithRetry(
m_SessionId,
[&]() -> CurlResult {
- Session Sess = AllocSession(Url, {});
+ Session Sess = AllocSession(Url, Parameters);
CURL* H = Sess.Get();
Sess.SetHeaders(
diff --git a/src/zenhttp/clients/httpclientcurl.h b/src/zenhttp/clients/httpclientcurl.h
index b7fa52e6c..bdeb46633 100644
--- a/src/zenhttp/clients/httpclientcurl.h
+++ b/src/zenhttp/clients/httpclientcurl.h
@@ -21,7 +21,10 @@ public:
// HttpClientBase
- [[nodiscard]] virtual Response Put(std::string_view Url, const IoBuffer& Payload, const KeyValueMap& AdditionalHeader = {}) override;
+ [[nodiscard]] virtual Response Put(std::string_view Url,
+ const IoBuffer& Payload,
+ const KeyValueMap& AdditionalHeader = {},
+ const KeyValueMap& Parameters = {}) override;
[[nodiscard]] virtual Response Put(std::string_view Url, const KeyValueMap& Parameters = {}) override;
[[nodiscard]] virtual Response Get(std::string_view Url,
const KeyValueMap& AdditionalHeader = {},
diff --git a/src/zenhttp/httpclient.cpp b/src/zenhttp/httpclient.cpp
index 13c86e9ae..4000ea8a8 100644
--- a/src/zenhttp/httpclient.cpp
+++ b/src/zenhttp/httpclient.cpp
@@ -415,9 +415,12 @@ HttpClient::SetSessionId(const Oid& SessionId)
}
HttpClient::Response
-HttpClient::Put(std::string_view Url, const IoBuffer& Payload, const HttpClient::KeyValueMap& AdditionalHeader)
+HttpClient::Put(std::string_view Url,
+ const IoBuffer& Payload,
+ const HttpClient::KeyValueMap& AdditionalHeader,
+ const HttpClient::KeyValueMap& Parameters)
{
- return m_Inner->Put(Url, Payload, AdditionalHeader);
+ return m_Inner->Put(Url, Payload, AdditionalHeader, Parameters);
}
HttpClient::Response
diff --git a/src/zenhttp/httpclient_test.cpp b/src/zenhttp/httpclient_test.cpp
index 7a657c464..af653cbb2 100644
--- a/src/zenhttp/httpclient_test.cpp
+++ b/src/zenhttp/httpclient_test.cpp
@@ -492,6 +492,17 @@ TEST_CASE("httpclient.put")
CHECK_EQ(Resp.StatusCode, HttpResponseCode::Created);
CHECK_EQ(Resp.AsText(), "resource created");
}
+
+ SUBCASE("PUT with payload and query parameters")
+ {
+ const char* Payload = "put payload data";
+ IoBuffer Buf(IoBuffer::Clone, Payload, strlen(Payload));
+ Buf.SetContentType(ZenContentType::kText);
+
+ HttpClient::Response Resp = Client.Put("/api/test/echo/uri", Buf, {}, {{"key", "value"}});
+ CHECK(Resp.IsSuccess());
+ CHECK_EQ(Resp.AsText(), "echo/uri\nkey=value");
+ }
}
TEST_CASE("httpclient.upload")
diff --git a/src/zenhttp/include/zenhttp/httpclient.h b/src/zenhttp/include/zenhttp/httpclient.h
index 9531b9366..b0d74951e 100644
--- a/src/zenhttp/include/zenhttp/httpclient.h
+++ b/src/zenhttp/include/zenhttp/httpclient.h
@@ -326,7 +326,10 @@ public:
return std::make_pair("Accept", MapContentTypeToString(ContentType));
}
- [[nodiscard]] Response Put(std::string_view Url, const IoBuffer& Payload, const KeyValueMap& AdditionalHeader = {});
+ [[nodiscard]] Response Put(std::string_view Url,
+ const IoBuffer& Payload,
+ const KeyValueMap& AdditionalHeader = {},
+ const KeyValueMap& Parameters = {});
[[nodiscard]] Response Put(std::string_view Url, const KeyValueMap& Parameters = {});
[[nodiscard]] Response Get(std::string_view Url, const KeyValueMap& AdditionalHeader = {}, const KeyValueMap& Parameters = {});
[[nodiscard]] Response Head(std::string_view Url, const KeyValueMap& AdditionalHeader = {});