diff options
Diffstat (limited to 'plugins/check_http.c')
-rw-r--r-- | plugins/check_http.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index 69ed2fa..df5daf2 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -187,6 +187,7 @@ process_arguments (int argc, char **argv) | |||
187 | {"nohtml", no_argument, 0, 'n'}, | 187 | {"nohtml", no_argument, 0, 'n'}, |
188 | {"ssl", no_argument, 0, 'S'}, | 188 | {"ssl", no_argument, 0, 'S'}, |
189 | {"post", required_argument, 0, 'P'}, | 189 | {"post", required_argument, 0, 'P'}, |
190 | {"method", required_argument, 0, 'j'}, | ||
190 | {"IP-address", required_argument, 0, 'I'}, | 191 | {"IP-address", required_argument, 0, 'I'}, |
191 | {"url", required_argument, 0, 'u'}, | 192 | {"url", required_argument, 0, 'u'}, |
192 | {"port", required_argument, 0, 'p'}, | 193 | {"port", required_argument, 0, 'p'}, |
@@ -228,7 +229,7 @@ process_arguments (int argc, char **argv) | |||
228 | } | 229 | } |
229 | 230 | ||
230 | while (1) { | 231 | while (1) { |
231 | c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:T:I:a:e:p:s:R:r:u:f:C:nlLSm:M:N", longopts, &option); | 232 | c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:e:p:s:R:r:u:f:C:nlLSm:M:N", longopts, &option); |
232 | if (c == -1 || c == EOF) | 233 | if (c == -1 || c == EOF) |
233 | break; | 234 | break; |
234 | 235 | ||
@@ -344,10 +345,16 @@ process_arguments (int argc, char **argv) | |||
344 | strncpy (user_auth, optarg, MAX_INPUT_BUFFER - 1); | 345 | strncpy (user_auth, optarg, MAX_INPUT_BUFFER - 1); |
345 | user_auth[MAX_INPUT_BUFFER - 1] = 0; | 346 | user_auth[MAX_INPUT_BUFFER - 1] = 0; |
346 | break; | 347 | break; |
347 | case 'P': /* HTTP POST data in URL encoded format */ | 348 | case 'P': /* HTTP POST data in URL encoded format; ignored if settings already */ |
348 | if (http_method || http_post_data) break; | 349 | if (! http_post_data) |
349 | http_method = strdup("POST"); | 350 | http_post_data = strdup (optarg); |
350 | http_post_data = strdup (optarg); | 351 | if (! http_method) |
352 | http_method = strdup("POST"); | ||
353 | break; | ||
354 | case 'j': /* Set HTTP method */ | ||
355 | if (http_method) | ||
356 | free(http_method); | ||
357 | http_method = strdup (optarg); | ||
351 | break; | 358 | break; |
352 | case 's': /* string or substring */ | 359 | case 's': /* string or substring */ |
353 | strncpy (string_expect, optarg, MAX_INPUT_BUFFER - 1); | 360 | strncpy (string_expect, optarg, MAX_INPUT_BUFFER - 1); |
@@ -817,7 +824,7 @@ check_http (void) | |||
817 | asprintf (&buf, "%sAuthorization: Basic %s\r\n", buf, auth); | 824 | asprintf (&buf, "%sAuthorization: Basic %s\r\n", buf, auth); |
818 | } | 825 | } |
819 | 826 | ||
820 | /* either send http POST data */ | 827 | /* either send http POST data (any data, not only POST)*/ |
821 | if (http_post_data) { | 828 | if (http_post_data) { |
822 | if (http_content_type) { | 829 | if (http_content_type) { |
823 | asprintf (&buf, "%sContent-Type: %s\r\n", buf, http_content_type); | 830 | asprintf (&buf, "%sContent-Type: %s\r\n", buf, http_content_type); |
@@ -1313,6 +1320,8 @@ print_help (void) | |||
1313 | printf (" %s\n", _("URL to GET or POST (default: /)")); | 1320 | printf (" %s\n", _("URL to GET or POST (default: /)")); |
1314 | printf (" %s\n", "-P, --post=STRING"); | 1321 | printf (" %s\n", "-P, --post=STRING"); |
1315 | printf (" %s\n", _("URL encoded http POST data")); | 1322 | printf (" %s\n", _("URL encoded http POST data")); |
1323 | printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE)"); | ||
1324 | printf (" %s\n", _("Set HTTP method.")); | ||
1316 | printf (" %s\n", "-N, --no-body"); | 1325 | printf (" %s\n", "-N, --no-body"); |
1317 | printf (" %s\n", _("Don't wait for document body: stop reading after headers.")); | 1326 | printf (" %s\n", _("Don't wait for document body: stop reading after headers.")); |
1318 | printf (" %s\n", _("(Note that this still does an HTTP GET or POST, not a HEAD.)")); | 1327 | printf (" %s\n", _("(Note that this still does an HTTP GET or POST, not a HEAD.)")); |
@@ -1396,5 +1405,5 @@ print_usage (void) | |||
1396 | printf (" [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n"); | 1405 | printf (" [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n"); |
1397 | printf (" [-s string] [-l] [-r <regex> | -R <case-insensitive regex>] [-P string]\n"); | 1406 | printf (" [-s string] [-l] [-r <regex> | -R <case-insensitive regex>] [-P string]\n"); |
1398 | printf (" [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>] [-A string]\n"); | 1407 | printf (" [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>] [-A string]\n"); |
1399 | printf (" [-k string] [-S] [-C <age>] [-T <content-type>]\n"); | 1408 | printf (" [-k string] [-S] [-C <age>] [-T <content-type>] [-j method]\n"); |
1400 | } | 1409 | } |