summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/connection.hpp7
-rw-r--r--include/curl_wrapper.hpp10
-rw-r--r--include/instance.hpp30
3 files changed, 44 insertions, 3 deletions
diff --git a/include/connection.hpp b/include/connection.hpp
index 761f777..27119e4 100644
--- a/include/connection.hpp
+++ b/include/connection.hpp
@@ -82,7 +82,12 @@ public:
*
* @since 0.1.0
*/
- explicit Connection(Instance &instance);
+ explicit Connection(Instance &instance)
+ : _instance{instance}
+ , _baseuri{instance.get_baseuri()}
+ {
+ _instance.copy_connection_properties(*this);
+ }
/*!
* @brief Make a HTTP GET call with parameters.
diff --git a/include/curl_wrapper.hpp b/include/curl_wrapper.hpp
index f8e567b..0759e01 100644
--- a/include/curl_wrapper.hpp
+++ b/include/curl_wrapper.hpp
@@ -189,6 +189,16 @@ public:
return sbuf;
}
+ /*!
+ * @brief Set some properties of the connection.
+ *
+ * Meant for internal use. See Instance::copy_connection_properties().
+ *
+ * @since 0.3.0
+ */
+ void setup_connection_properties(string_view proxy, string_view access_token,
+ string_view cainfo);
+
protected:
/*!
* @brief Mutex for #get_buffer a.k.a. _curl_buffer_body.
diff --git a/include/instance.hpp b/include/instance.hpp
index 6185b7f..85756e9 100644
--- a/include/instance.hpp
+++ b/include/instance.hpp
@@ -53,7 +53,28 @@ public:
*
* @since 0.1.0
*/
- explicit Instance(string_view hostname, string_view access_token);
+ explicit Instance(const string_view hostname,
+ const string_view access_token)
+ : _hostname{hostname}
+ , _baseuri{"https://" + _hostname}
+ , _access_token{access_token}
+ , _max_chars{0}
+ {}
+
+ /*!
+ * @brief Set the properties of the connection of the calling class up.
+ *
+ * Meant for internal use. This aligns the properties of the connection of
+ * the calling class with the properties of connection of this class.
+ *
+ * @param curlwrapper The CURLWrapper parent of the calling class.
+ *
+ * @since 0.3.0
+ */
+ inline void copy_connection_properties(CURLWrapper &curlwrapper)
+ {
+ curlwrapper.setup_connection_properties(_proxy, _access_token, _cainfo);
+ }
/*!
* @brief Returns the hostname.
@@ -223,7 +244,12 @@ public:
class ObtainToken : public CURLWrapper
{
public:
- ObtainToken(Instance &instance);
+ ObtainToken(Instance &instance)
+ : _instance{instance}
+ , _baseuri{instance.get_baseuri()}
+ {
+ _instance.copy_connection_properties(*this);
+ }
/*!
* @brief Creates an application via `/api/v1/apps`.