int format;
CURL *curl;
+ struct curl_slist *headers;
char curl_errbuf[CURL_ERROR_SIZE];
- char send_buffer[4096];
+ char *send_buffer;
+ size_t send_buffer_size;
size_t send_buffer_free;
size_t send_buffer_fill;
cdtime_t send_buffer_init_time;
return (-1);
}
+ if (cb->low_speed_limit > 0 && cb->low_speed_time > 0)
+ {
+ curl_easy_setopt (cb->curl, CURLOPT_LOW_SPEED_LIMIT,
+ (long) (cb->low_speed_limit * cb->low_speed_time));
+ curl_easy_setopt (cb->curl, CURLOPT_LOW_SPEED_TIME,
+ (long) cb->low_speed_time);
+ }
+
+#ifdef HAVE_CURLOPT_TIMEOUT_MS
+ if (cb->timeout > 0)
+ curl_easy_setopt (cb->curl, CURLOPT_TIMEOUT_MS, (long) cb->timeout);
+#endif
+
curl_easy_setopt (cb->curl, CURLOPT_NOSIGNAL, 1L);
- curl_easy_setopt (cb->curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
+ curl_easy_setopt (cb->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
- headers = NULL;
- headers = curl_slist_append (headers, "Accept: */*");
+ cb->headers = NULL;
+ cb->headers = curl_slist_append (cb->headers, "Accept: */*");
if (cb->format == WH_FORMAT_JSON)
- headers = curl_slist_append (headers, "Content-Type: application/json");
+ cb->headers = curl_slist_append (cb->headers, "Content-Type: application/json");
else
- headers = curl_slist_append (headers, "Content-Type: text/plain");
- headers = curl_slist_append (headers, "Expect:");
- curl_easy_setopt (cb->curl, CURLOPT_HTTPHEADER, headers);
+ cb->headers = curl_slist_append (cb->headers, "Content-Type: text/plain");
+ cb->headers = curl_slist_append (cb->headers, "Expect:");
+ curl_easy_setopt (cb->curl, CURLOPT_HTTPHEADER, cb->headers);
curl_easy_setopt (cb->curl, CURLOPT_ERRORBUFFER, cb->curl_errbuf);
curl_easy_setopt (cb->curl, CURLOPT_URL, cb->location);
wh_flush_nolock (/* timeout = */ 0, cb);
- curl_easy_cleanup (cb->curl);
+ if (cb->curl != NULL)
+ {
+ curl_easy_cleanup (cb->curl);
+ cb->curl = NULL;
+ }
+
+ if (cb->headers != NULL)
+ {
+ curl_slist_free_all (cb->headers);
+ cb->headers = NULL;
+ }
+
+ sfree (cb->name);
sfree (cb->location);
sfree (cb->user);
sfree (cb->pass);
return (-1);
}
memset (cb, 0, sizeof (*cb));
- cb->location = NULL;
- cb->user = NULL;
- cb->pass = NULL;
- cb->credentials = NULL;
cb->verify_peer = 1;
cb->verify_host = 1;
- cb->cacert = NULL;
cb->format = WH_FORMAT_COMMAND;
++<<<<<<< HEAD
+ cb->sslversion = CURL_SSLVERSION_DEFAULT;
+ cb->low_speed_limit = 0;
+ cb->timeout = 0;
++=======
+ cb->curl = NULL;
+ cb->headers = NULL;
++>>>>>>> collectd-5.4
pthread_mutex_init (&cb->send_lock, /* attr = */ NULL);