Commit 6f038e07 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Remove unecessary/multiple times HTTP header

parent 1df612c0
...@@ -164,8 +164,8 @@ smf_sbi::smf_sbi() { ...@@ -164,8 +164,8 @@ smf_sbi::smf_sbi() {
handles = {}; handles = {};
headers = nullptr; headers = nullptr;
headers = curl_slist_append(headers, "Accept: application/json"); headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "charsets: utf-8"); headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(headers, "Content-Type: application/json");
if ((code < 0) or (curl_multi == nullptr) or (headers == nullptr)) { if ((code < 0) or (curl_multi == nullptr) or (headers == nullptr)) {
Logger::smf_sbi().error("Cannot initialize Curl Multi Interface"); Logger::smf_sbi().error("Cannot initialize Curl Multi Interface");
...@@ -1092,10 +1092,16 @@ bool smf_sbi::curl_create_handle( ...@@ -1092,10 +1092,16 @@ bool smf_sbi::curl_create_handle(
// Create handle for a curl request // Create handle for a curl request
CURL* curl = curl_easy_init(); CURL* curl = curl_easy_init();
curl_slist_free_all(slist);
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "charsets: utf-8");
if (is_multipart) { if (is_multipart) {
std::string content_type = "content-type: multipart/related; boundary=" + std::string content_type = "content-type: multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY); std::string(CURL_MIME_BOUNDARY);
headers = curl_slist_append(headers, content_type.c_str()); headers = curl_slist_append(headers, content_type.c_str());
} else {
headers = curl_slist_append(headers, "Content-Type: application/json");
} }
if ((curl == nullptr) or (headers == nullptr)) { if ((curl == nullptr) or (headers == nullptr)) {
...@@ -1153,6 +1159,11 @@ bool smf_sbi::curl_create_handle( ...@@ -1153,6 +1159,11 @@ bool smf_sbi::curl_create_handle(
// Create handle for a curl request // Create handle for a curl request
CURL* curl = curl_easy_init(); CURL* curl = curl_easy_init();
curl_slist_free_all(slist);
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(headers, "Content-Type: application/json");
if ((curl == nullptr) or (headers == nullptr)) { if ((curl == nullptr) or (headers == nullptr)) {
Logger::smf_sbi().error("Cannot initialize a new Curl Handle"); Logger::smf_sbi().error("Cannot initialize a new Curl Handle");
return false; return false;
...@@ -1212,6 +1223,11 @@ bool smf_sbi::curl_create_handle( ...@@ -1212,6 +1223,11 @@ bool smf_sbi::curl_create_handle(
// Create handle for a curl request // Create handle for a curl request
CURL* curl = curl_easy_init(); CURL* curl = curl_easy_init();
curl_slist_free_all(slist);
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(headers, "Content-Type: application/json");
if ((curl == nullptr) or (headers == nullptr)) { if ((curl == nullptr) or (headers == nullptr)) {
Logger::smf_sbi().error("Cannot initialize a new Curl Handle"); Logger::smf_sbi().error("Cannot initialize a new Curl Handle");
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment