File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed
Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -41,8 +41,8 @@ typedef struct {
4141 HeaderFields headers;
4242} Response;
4343
44- // init function
45- void init ();
44+ // init and disable functions
45+ int init ();
4646void disable ();
4747
4848/* *
Original file line number Diff line number Diff line change 1212 */
1313
1414#include " restclient-cpp/restclient.h"
15- #include " restclient-cpp/version.h"
1615
16+ #include < curl/curl.h>
17+
18+ #include " restclient-cpp/version.h"
1719#include " restclient-cpp/connection.h"
1820
21+ /* *
22+ * @brief global init function. Call this before you start any threads.
23+ */
24+ int RestClient::init () {
25+ CURLcode res = curl_global_init (CURL_GLOBAL_ALL);
26+ if (res == CURLE_OK) {
27+ return 0 ;
28+ } else {
29+ return 1 ;
30+ }
31+ }
32+
33+ /* *
34+ * @brief global disable function. Call this before you terminate your
35+ * program.
36+ */
37+ void RestClient::disable () {
38+ curl_global_cleanup ();
39+ }
40+
1941/* *
2042 * @brief HTTP GET method
2143 *
Original file line number Diff line number Diff line change @@ -17,10 +17,12 @@ class RestClientTest : public ::testing::Test
1717
1818 virtual void SetUp ()
1919 {
20+ RestClient::init ();
2021 }
2122
2223 virtual void TearDown ()
2324 {
25+ RestClient::disable ();
2426 }
2527
2628};
You can’t perform that action at this time.
0 commit comments