X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fhttp.c;h=99a6db3204ffad9fb2d054a0c3987dbe0717e6c3;hb=31fc078cb1ec387eea7d41413a98904150cc46ae;hp=f2351c9e31c16d2f76dda020a590a68c71b18b38;hpb=5969698ff6028947e097927e2391406481a36290;p=ppastats.git diff --git a/src/http.c b/src/http.c index f2351c9..99a6db3 100644 --- a/src/http.c +++ b/src/http.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2012 jeanfi@gmail.com + * Copyright (C) 2011-2014 jeanfi@gmail.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -28,9 +28,9 @@ #include "fcache.h" #include "http.h" -#include "log.h" +#include -static const int DEFAULT_FETCH_RETRIES = 10; +static const int DEFAULT_FETCH_RETRIES = 15; static CURL *curl; @@ -91,6 +91,10 @@ static char *fetch_url(const char *url) curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cbk_curl); curl_easy_setopt(curl, CURLOPT_WRITEDATA, content); curl_easy_setopt(curl, CURLOPT_USERAGENT, "ppastats/0.0"); +#ifdef CURLOPT_TRANSFER_ENCODING + /* added since Curl 7.21.7 */ + curl_easy_setopt(curl, CURLOPT_TRANSFER_ENCODING, 1); +#endif if (curl_easy_perform(curl) == CURLE_OK) { curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code); @@ -135,10 +139,12 @@ static char *fetch_url(const char *url) void http_cleanup() { - log_debug(_("cleanup CURL")); + log_fct_enter(); curl_easy_cleanup(curl); curl_global_cleanup(); + + log_fct_exit(); } char *get_url_content(const char *url, unsigned int use_cache) @@ -150,13 +156,11 @@ char *get_url_content(const char *url, unsigned int use_cache) if (use_cache) content = fcache_get(url + 7); - if (!content) { + if (!content) content = fetch_url(url); - } if (use_cache && content) fcache_put(url + 7, content); return content; } -