diff --git a/src/sota_tools/request_pool.cc b/src/sota_tools/request_pool.cc index 3b99ab3519..eefa543e3a 100644 --- a/src/sota_tools/request_pool.cc +++ b/src/sota_tools/request_pool.cc @@ -12,6 +12,14 @@ RequestPool::RequestPool(const TreehubServer& server, const int max_curl_request curl_global_init(CURL_GLOBAL_DEFAULT); multi_ = curl_multi_init(); curl_multi_setopt(multi_, CURLMOPT_PIPELINING, CURLPIPE_HTTP1 | CURLPIPE_MULTIPLEX); + + curl = curl_easy_init(); + if (curl == nullptr) { + throw std::runtime_error("Could not initialize curl"); + } + headers = nullptr; + headers = curl_slist_append(headers, "Content-Type: application/octet-stream"); + curlEasySetoptWrapper(curl, CURLOPT_HTTPHEADER, headers); } RequestPool::~RequestPool() { @@ -26,6 +34,8 @@ RequestPool::~RequestPool() { curl_multi_cleanup(multi_); curl_global_cleanup(); + curl_slist_free_all(headers); + curl_easy_cleanup(curl); } catch (std::exception& ex) { LOG_ERROR << "Exception in RequestPool dtor: " << ex.what(); } catch (...) { diff --git a/src/sota_tools/request_pool.h b/src/sota_tools/request_pool.h index 8db5e88c71..3b079c064b 100644 --- a/src/sota_tools/request_pool.h +++ b/src/sota_tools/request_pool.h @@ -44,6 +44,8 @@ class RequestPool { int total_requests_made_{0}; const TreehubServer& server_; CURLM* multi_; + CURL* curl; + curl_slist* headers; std::list query_queue_; std::list upload_queue_; RunMode mode_;