X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fapache.c;h=baa6081a6046743679a6949b16d2f07e347aed24;hb=f81aafecc0b537b4bec734f7fdb0c8352719afee;hp=b306032b6c55fddb512b17c0fb24aa252271dbf2;hpb=ac077f078300f47d5a6b75aaeeb0999799309283;p=collectd.git diff --git a/src/apache.c b/src/apache.c index b306032b..baa6081a 100644 --- a/src/apache.c +++ b/src/apache.c @@ -175,13 +175,12 @@ static int config_add (oconfig_item_t *ci) int i; int status; - st = malloc (sizeof (*st)); + st = calloc (1, sizeof (*st)); if (st == NULL) { - ERROR ("apache plugin: malloc failed."); + ERROR ("apache plugin: calloc failed."); return (-1); } - memset (st, 0, sizeof (*st)); st->timeout = -1; @@ -530,13 +529,16 @@ static int apache_read_host (user_data_t *user_data) /* {{{ */ st = user_data->data; + int status; + + char *content_type; + static const char *text_plain = "text/plain"; + assert (st->url != NULL); /* (Assured by `config_add') */ if (st->curl == NULL) { - int status; - status = init_host (st); if (status != 0) return (-1); @@ -559,6 +561,16 @@ static int apache_read_host (user_data_t *user_data) /* {{{ */ st->server_type = APACHE; } + status = curl_easy_getinfo (st->curl, CURLINFO_CONTENT_TYPE, &content_type); + if ((status == CURLE_OK) && (content_type != NULL) && + (strncasecmp (content_type, text_plain, strlen (text_plain)) != 0)) + { + WARNING ("apache plugin: `Content-Type' response header is not `%s' " + "(received: `%s'). Expecting unparseable data. Please check `URL' " + "parameter (missing `?auto' suffix ?)", + text_plain, content_type); + } + ptr = st->apache_buffer; saveptr = NULL; while ((line = strtok_r (ptr, "\n\r", &saveptr)) != NULL)