From 2d542a79796fb4568871c4a634ce4d3b311ffd9d Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 4 Aug 2019 11:33:58 +0200 Subject: Fixed curl call orders --- common/http.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'common/http.c') diff --git a/common/http.c b/common/http.c index 275a18f..88e15cd 100644 --- a/common/http.c +++ b/common/http.c @@ -53,6 +53,9 @@ void http_clean(void) const char * http_get(const char* path) { + curl_easy_reset(curl); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &writeCallback); + curl_easy_setopt(curl, CURLOPT_POST, 0); return http_perform(path, NULL); } @@ -80,9 +83,6 @@ const char * http_perform(const char* path, const char* postfields) buffer_fill = 0; } - curl_easy_reset(curl); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &writeCallback); - const char * weburl = config_get_web_url(); size_t weburl_len = strlen(weburl); size_t path_len = strlen(path); @@ -106,6 +106,9 @@ const char * http_perform(const char* path, const char* postfields) const char * http_post(const char* path, const char* postfields) { + curl_easy_reset(curl); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &writeCallback); + if (postfields == NULL) curl_easy_setopt(curl, CURLOPT_POST, 1); return http_perform(path, postfields); -- cgit v1.2.3