From a9e1e16709580ec75ee86a3108de1b57c5376c36 Mon Sep 17 00:00:00 2001 From: Pranay Sharma Date: Thu, 18 Dec 2014 11:40:55 +0530 Subject: [PATCH] Added correct headers for the Daemon to POST json content --- src/daemon.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/daemon.cpp b/src/daemon.cpp index 632067b..e969aec 100644 --- a/src/daemon.cpp +++ b/src/daemon.cpp @@ -450,11 +450,19 @@ bool uploadPost(std::string url, std::string data) bool success = true; CURL *curl; CURLcode res; - + struct curl_slist *headers=NULL; // init to NULL is important + + /* Add the required headers */ + 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"); /* get a curl handle */ curl = curl_easy_init(); if(curl) { + /* Add the headers */ + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); + /* First set the URL that is about to receive our POST. This URL can just as well be a https:// URL if that is what should receive the data. */