summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-05-04 21:21:20 +0200
committerSven Nierlein <sven@nierlein.de>2018-10-22 16:30:31 +0200
commitf0cebd5153d759fe663488a1750fcbe0f5e680a1 (patch)
treea8cc2f3b39655b9e56bec0d4050a0ddc52833b0f /plugins
parent94d017c5ab26c65fbcc1e531210d953b5bad69a6 (diff)
downloadmonitoring-plugins-f0cebd5153d759fe663488a1750fcbe0f5e680a1.tar.gz
fixed failing tests due to wrong content_length calculation
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_curl.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index a2ded891..5f6905f9 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -1715,6 +1715,7 @@ check_document_dates (const curlhelp_write_curlbuf *header_buf, char (*msg)[DEFA
1715 return date_result; 1715 return date_result;
1716} 1716}
1717 1717
1718
1718int 1719int
1719get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_write_curlbuf* body_buf) 1720get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_write_curlbuf* body_buf)
1720{ 1721{
@@ -1733,15 +1734,17 @@ get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_wri
1733 1734
1734 content_length_s = get_header_value (headers, nof_headers, "content-length"); 1735 content_length_s = get_header_value (headers, nof_headers, "content-length");
1735 if (!content_length_s) { 1736 if (!content_length_s) {
1736 /* TODO: or header_buf->buflen + body_buf->buflen */ 1737 return header_buf->buflen + body_buf->buflen;
1737 return body_buf->buflen;
1738 } 1738 }
1739 /* TODO: trim */ 1739 content_length_s += strspn (content_length_s, " \t");
1740 content_length = atoi (content_length_s); 1740 content_length = atoi (content_length_s);
1741 if (content_length != body_buf->buflen) {
1742 /* TODO: should we warn if the actual and the reported body length doen't match? */
1743 }
1741 1744
1742 if (content_length_s) free (content_length_s); 1745 if (content_length_s) free (content_length_s);
1743 1746
1744 return content_length; 1747 return header_buf->buflen + body_buf->buflen;
1745} 1748}
1746 1749
1747/* TODO: is there a better way in libcurl to check for the SSL library? */ 1750/* TODO: is there a better way in libcurl to check for the SSL library? */