aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2025-09-30 19:07:51 +0200
committerGitHub Enterprise <[email protected]>2025-09-30 19:07:51 +0200
commit634181a04efff90def7a98d98eac7078e1d4e62d (patch)
tree04678bba636a76d21f300ff6e73af4473274cf12 /src/zenhttp/include
parentuse batching clang-format for quicker turnaround on validate actions (#529) (diff)
downloadzen-634181a04efff90def7a98d98eac7078e1d4e62d.tar.xz
zen-634181a04efff90def7a98d98eac7078e1d4e62d.zip
HttpClient support for pluggable back-ends (#532)
refactored HttpClient to separate out cpr implementation into separate classes, with an abstract base class to allow plugging in multiple implementations in the future
Diffstat (limited to 'src/zenhttp/include')
-rw-r--r--src/zenhttp/include/zenhttp/httpclient.h23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/zenhttp/include/zenhttp/httpclient.h b/src/zenhttp/include/zenhttp/httpclient.h
index ec06aa229..aae7b94e5 100644
--- a/src/zenhttp/include/zenhttp/httpclient.h
+++ b/src/zenhttp/include/zenhttp/httpclient.h
@@ -108,6 +108,8 @@ private:
const HttpResponseCode m_ResponseCode = HttpResponseCode::ImATeapot;
};
+class HttpClientBase;
+
class HttpClient
{
public:
@@ -191,6 +193,11 @@ public:
std::string ErrorMessage(std::string_view Prefix) const;
};
+ static std::pair<std::string_view, std::string_view> Accept(ZenContentType ContentType)
+ {
+ 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 KeyValueMap& Parameters = {});
[[nodiscard]] Response Get(std::string_view Url, const KeyValueMap& AdditionalHeader = {}, const KeyValueMap& Parameters = {});
@@ -220,27 +227,19 @@ public:
[[nodiscard]] Response TransactPackage(std::string_view Url, CbPackage Package, const KeyValueMap& AdditionalHeader = {});
- static std::pair<std::string_view, std::string_view> Accept(ZenContentType ContentType)
- {
- return std::make_pair("Accept", MapContentTypeToString(ContentType));
- }
-
- LoggerRef Logger() { return m_Log; }
+ LoggerRef Log() { return m_Log; }
std::string_view GetBaseUri() const { return m_BaseUri; }
- bool Authenticate();
std::string_view GetSessionId() const { return m_SessionId; }
+ bool Authenticate();
+
private:
- const std::optional<HttpClientAccessToken> GetAccessToken();
- struct Impl;
+ HttpClientBase* m_Inner;
LoggerRef m_Log;
std::string m_BaseUri;
std::string m_SessionId;
const HttpClientSettings m_ConnectionSettings;
- RwLock m_AccessTokenLock;
- HttpClientAccessToken m_CachedAccessToken;
- Ref<Impl> m_Impl;
};
void httpclient_forcelink(); // internal