summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_curl.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 59e398b2..d4442f51 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -206,6 +206,7 @@ int maximum_age = -1;
206int address_family = AF_UNSPEC; 206int address_family = AF_UNSPEC;
207curlhelp_ssl_library ssl_library = CURLHELP_SSL_LIBRARY_UNKNOWN; 207curlhelp_ssl_library ssl_library = CURLHELP_SSL_LIBRARY_UNKNOWN;
208int curl_http_version = CURL_HTTP_VERSION_NONE; 208int curl_http_version = CURL_HTTP_VERSION_NONE;
209int automatic_decompression = FALSE;
209 210
210int process_arguments (int, char**); 211int process_arguments (int, char**);
211void handle_curl_option_return_code (CURLcode res, const char* option); 212void handle_curl_option_return_code (CURLcode res, const char* option);
@@ -383,6 +384,13 @@ check_http (void)
383 /* print everything on stdout like check_http would do */ 384 /* print everything on stdout like check_http would do */
384 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_STDERR, stdout), "CURLOPT_STDERR"); 385 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_STDERR, stdout), "CURLOPT_STDERR");
385 386
387 if (automatic_decompression)
388#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 21, 6)
389 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, ""), "CURLOPT_ACCEPT_ENCODING");
390#else
391 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_ENCODING, ""), "CURLOPT_ENCODING");
392#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 21, 6) */
393
386 /* initialize buffer for body of the answer */ 394 /* initialize buffer for body of the answer */
387 if (curlhelp_initwritebuffer(&body_buf) < 0) 395 if (curlhelp_initwritebuffer(&body_buf) < 0)
388 die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for body\n"); 396 die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for body\n");
@@ -1149,7 +1157,8 @@ process_arguments (int argc, char **argv)
1149 INVERT_REGEX = CHAR_MAX + 1, 1157 INVERT_REGEX = CHAR_MAX + 1,
1150 SNI_OPTION, 1158 SNI_OPTION,
1151 CA_CERT_OPTION, 1159 CA_CERT_OPTION,
1152 HTTP_VERSION_OPTION 1160 HTTP_VERSION_OPTION,
1161 AUTOMATIC_DECOMPRESSION
1153 }; 1162 };
1154 1163
1155 int option = 0; 1164 int option = 0;
@@ -1192,6 +1201,7 @@ process_arguments (int argc, char **argv)
1192 {"extended-perfdata", no_argument, 0, 'E'}, 1201 {"extended-perfdata", no_argument, 0, 'E'},
1193 {"show-body", no_argument, 0, 'B'}, 1202 {"show-body", no_argument, 0, 'B'},
1194 {"http-version", required_argument, 0, HTTP_VERSION_OPTION}, 1203 {"http-version", required_argument, 0, HTTP_VERSION_OPTION},
1204 {"enable-automatic-decompression", no_argument, 0, AUTOMATIC_DECOMPRESSION},
1195 {0, 0, 0, 0} 1205 {0, 0, 0, 0}
1196 }; 1206 };
1197 1207
@@ -1583,6 +1593,9 @@ process_arguments (int argc, char **argv)
1583 exit (STATE_WARNING); 1593 exit (STATE_WARNING);
1584 } 1594 }
1585 break; 1595 break;
1596 case AUTOMATIC_DECOMPRESSION:
1597 automatic_decompression = TRUE;
1598 break;
1586 case '?': 1599 case '?':
1587 /* print short usage statement if args not parsable */ 1600 /* print short usage statement if args not parsable */
1588 usage5 (); 1601 usage5 ();
@@ -1793,6 +1806,8 @@ print_help (void)
1793 printf (" %s\n", "--http-version=VERSION"); 1806 printf (" %s\n", "--http-version=VERSION");
1794 printf (" %s\n", _("Connect via specific HTTP protocol.")); 1807 printf (" %s\n", _("Connect via specific HTTP protocol."));
1795 printf (" %s\n", _("1.0 = HTTP/1.0, 1.1 = HTTP/1.1, 2.0 = HTTP/2 (HTTP/2 will fail without -S)")); 1808 printf (" %s\n", _("1.0 = HTTP/1.0, 1.1 = HTTP/1.1, 2.0 = HTTP/2 (HTTP/2 will fail without -S)"));
1809 printf (" %s\n", "--enable-automatic-decompression");
1810 printf (" %s\n", _("Enable automatic decompression of body (CURLOPT_ACCEPT_ENCODING)."));
1796 printf ("\n"); 1811 printf ("\n");
1797 1812
1798 printf (UT_WARN_CRIT); 1813 printf (UT_WARN_CRIT);