X-Git-Url: https://git.wpitchoune.net/gitweb/?p=prss.git;a=blobdiff_plain;f=src%2Fhttp.c;h=55eab0fb6a54a534c61628dc5457d92a3f6a0621;hp=e663b8615f57f8007fc725bd24f3bbbd007bab2c;hb=1070b8de5c6cdf5e5958675a1b90f0af3e3f4688;hpb=4c8273864b951d26b002c8f2ec6e92a9a13799b6 diff --git a/src/http.c b/src/http.c index e663b86..55eab0f 100644 --- a/src/http.c +++ b/src/http.c @@ -28,6 +28,8 @@ #include "http.h" +static int debug = 1; + struct ucontent { char *data; size_t len; @@ -54,7 +56,8 @@ static size_t cbk_curl(void *buffer, size_t size, size_t nmemb, void *userp) void http_init() { - curl = curl_easy_init(); + if (!curl) + curl = curl_easy_init(); } void http_cleanup() @@ -97,12 +100,18 @@ json_object *http_json_get(const char *url, struct json_object *j) in = json_object_to_json_string(j); out = http_get(url, in); + + if (debug) + printf("HTTP request= %s\n", + json_object_to_json_string(j)); if (out) { result = json_tokener_parse(out); + if (debug) + printf("HTTP reply= %s\n", out); free(out); return result; - } + } return NULL; }