summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-05-04 21:21:20 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-05-04 21:21:20 +0200
commit55aeb1a5267dfc474446435c63a65acb2be7b3cd (patch)
treeff725803309b5f8665ea47348d49b57583ad5d75 /plugins
parent425962d9ce8abe925ed9f0e5c43d9b5996a6992b (diff)
downloadmonitoring-plugins-55aeb1a5267dfc474446435c63a65acb2be7b3cd.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? */