diff --git a/src/curl.c b/src/curl.c
index 32ba74527405a8393767a1901093fd571db01c3c..c6e2ae9c1f521350db159dc2922dafcb6fb54f41 100644 (file)
--- a/src/curl.c
+++ b/src/curl.c
int verify_peer;
int verify_host;
char *cacert;
+ struct curl_slist *headers;
+ char *post_body;
int response_time;
CURL *curl;
sfree (wp->pass);
sfree (wp->credentials);
sfree (wp->cacert);
+ sfree (wp->post_body);
+ curl_slist_free_all (wp->headers);
sfree (wp->buffer);
return (0);
} /* }}} int cc_config_add_string */
+static int cc_config_append_string (const char *name, struct curl_slist **dest, /* {{{ */
+ oconfig_item_t *ci)
+{
+ if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
+ {
+ WARNING ("curl plugin: `%s' needs exactly one string argument.", name);
+ return (-1);
+ }
+
+ *dest = curl_slist_append(*dest, ci->values[0].value.string);
+ if (*dest == NULL)
+ return (-1);
+
+ return (0);
+} /* }}} int cc_config_append_string */
+
+
static int cc_config_set_boolean (const char *name, int *dest, /* {{{ */
oconfig_item_t *ci)
{
wp->verify_host ? 2L : 0L);
if (wp->cacert != NULL)
curl_easy_setopt (wp->curl, CURLOPT_CAINFO, wp->cacert);
+ if (wp->headers != NULL)
+ curl_easy_setopt (wp->curl, CURLOPT_HTTPHEADER, wp->headers);
+ if (wp->post_body != NULL)
+ curl_easy_setopt (wp->curl, CURLOPT_POSTFIELDS, wp->post_body);
return (0);
} /* }}} int cc_page_init_curl */
else if (strcasecmp ("Match", child->key) == 0)
/* Be liberal with failing matches => don't set `status'. */
cc_config_add_match (page, child);
+ else if (strcasecmp ("Header", child->key) == 0)
+ status = cc_config_append_string ("Header", &page->headers, child);
+ else if (strcasecmp ("Post", child->key) == 0)
+ status = cc_config_add_string ("Post", &page->post_body, child);
else
{
WARNING ("curl plugin: Option `%s' not allowed here.", child->key);