[monitoring-plugins] fixed failing tests due to wrong content_length ...
Andreas Baumann
git at monitoring-plugins.org
Thu May 4 21:30:12 CEST 2017
Module: monitoring-plugins
Branch: feature_check_curl
Commit: 55aeb1a5267dfc474446435c63a65acb2be7b3cd
Author: Andreas Baumann <mail at andreasbaumann.cc>
Date: Thu May 4 21:21:20 2017 +0200
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=55aeb1a
fixed failing tests due to wrong content_length calculation
---
plugins/check_curl.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index a2ded89..5f6905f 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
return date_result;
}
+
int
get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_write_curlbuf* body_buf)
{
@@ -1733,15 +1734,17 @@ get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_wri
content_length_s = get_header_value (headers, nof_headers, "content-length");
if (!content_length_s) {
- /* TODO: or header_buf->buflen + body_buf->buflen */
- return body_buf->buflen;
+ return header_buf->buflen + body_buf->buflen;
}
- /* TODO: trim */
+ content_length_s += strspn (content_length_s, " \t");
content_length = atoi (content_length_s);
+ if (content_length != body_buf->buflen) {
+ /* TODO: should we warn if the actual and the reported body length doen't match? */
+ }
if (content_length_s) free (content_length_s);
- return content_length;
+ return header_buf->buflen + body_buf->buflen;
}
/* TODO: is there a better way in libcurl to check for the SSL library? */
More information about the Commits
mailing list