summaryrefslogtreecommitdiff
path: root/libpiano/src/http.c
diff options
context:
space:
mode:
Diffstat (limited to 'libpiano/src/http.c')
-rw-r--r--libpiano/src/http.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/libpiano/src/http.c b/libpiano/src/http.c
index ee63fef..52b2f2b 100644
--- a/libpiano/src/http.c
+++ b/libpiano/src/http.c
@@ -58,10 +58,12 @@ size_t PianoCurlRetToVar (void *ptr, size_t size, size_t nmemb, void *stream) {
* @param put received data here, memory is allocated by this function
* @return nothing yet
*/
-void PianoHttpPost (CURL *ch, char *url, char *postData, char **retData) {
+PianoReturn_t PianoHttpPost (CURL *ch, char *url, char *postData,
+ char **retData) {
struct curl_slist *headers = NULL;
/* Let's hope nothing will be bigger than this... */
char curlRet[PIANO_HTTP_BUFFER_SIZE];
+ PianoReturn_t ret;
headers = curl_slist_append (headers, "Content-Type: text/xml");
@@ -74,10 +76,16 @@ void PianoHttpPost (CURL *ch, char *url, char *postData, char **retData) {
memset (curlRet, 0, sizeof (curlRet));
curl_easy_setopt (ch, CURLOPT_WRITEDATA, curlRet);
- curl_easy_perform (ch);
+ if (curl_easy_perform (ch) == CURLE_OK) {
+ ret = PIANO_RET_OK;
+ *retData = calloc (strlen (curlRet) + 1, sizeof (char));
+ strcpy (*retData, curlRet);
+ } else {
+ ret = PIANO_RET_NET_ERROR;
+ *retData = NULL;
+ }
curl_slist_free_all (headers);
- *retData = calloc (strlen (curlRet) + 1, sizeof (char));
- strcpy (*retData, curlRet);
+ return ret;
}