X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnginx.c;h=b0daa05b31a555732a0f58940d732df84de3b57d;hb=cf19c40fd20c80cf4ca81143628b22470bccfc62;hp=e8282f23601c7c40516ee6e150e9ac7e8f740c81;hpb=ca316d91e178412604ea8462dc60a8bc32cbfc87;p=collectd.git diff --git a/src/nginx.c b/src/nginx.c index e8282f23..b0daa05b 100644 --- a/src/nginx.c +++ b/src/nginx.c @@ -113,8 +113,6 @@ static int config (const char *key, const char *value) static int init (void) { - static char credentials[1024]; - if (curl != NULL) curl_easy_cleanup (curl); @@ -131,6 +129,11 @@ static int init (void) if (user != NULL) { +#ifdef HAVE_CURLOPT_USERNAME + curl_easy_setopt (curl, CURLOPT_USERNAME, user); + curl_easy_setopt (curl, CURLOPT_PASSWORD, (pass == NULL) ? "" : pass); +#else + static char credentials[1024]; int status = ssnprintf (credentials, sizeof (credentials), "%s:%s", user, pass == NULL ? "" : pass); if ((status < 0) || ((size_t) status >= sizeof (credentials))) @@ -140,6 +143,7 @@ static int init (void) } curl_easy_setopt (curl, CURLOPT_USERPWD, credentials); +#endif } if (url != NULL)