summaryrefslogtreecommitdiffstats
path: root/plugins/check_http.c
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2004-02-20 03:21:40 +0000
committerTon Voon <tonvoon@users.sourceforge.net>2004-02-20 03:21:40 +0000
commit15e5ea295c05f0e609de4c744ffacf4440dfee9b (patch)
tree6ba1baecfcef31d8628dc123990a03438b3b91fb /plugins/check_http.c
parent55f8f712fb2808ff9e4c478d75aaf7895aa55c84 (diff)
downloadmonitoring-plugins-15e5ea295c05f0e609de4c744ffacf4440dfee9b.tar.gz
Added Content-type when POSTing (Shawn Wills)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@813 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_http.c')
-rw-r--r--plugins/check_http.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 8e45e88d..afd75d3d 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -111,6 +111,7 @@ int redir_depth = 0;
111int max_depth = 15; 111int max_depth = 15;
112char *http_method; 112char *http_method;
113char *http_post_data; 113char *http_post_data;
114char *http_content_type;
114char buffer[MAX_INPUT_BUFFER]; 115char buffer[MAX_INPUT_BUFFER];
115 116
116int process_arguments (int, char **); 117int process_arguments (int, char **);
@@ -207,6 +208,7 @@ process_arguments (int argc, char **argv)
207 {"linespan", no_argument, 0, 'l'}, 208 {"linespan", no_argument, 0, 'l'},
208 {"onredirect", required_argument, 0, 'f'}, 209 {"onredirect", required_argument, 0, 'f'},
209 {"certificate", required_argument, 0, 'C'}, 210 {"certificate", required_argument, 0, 'C'},
211 {"content-type", required_argument, 0, 'T'},
210 {"min", required_argument, 0, 'm'}, 212 {"min", required_argument, 0, 'm'},
211 {"use-ipv4", no_argument, 0, '4'}, 213 {"use-ipv4", no_argument, 0, '4'},
212 {"use-ipv6", no_argument, 0, '6'}, 214 {"use-ipv6", no_argument, 0, '6'},
@@ -345,6 +347,9 @@ process_arguments (int argc, char **argv)
345 server_expect[MAX_INPUT_BUFFER - 1] = 0; 347 server_expect[MAX_INPUT_BUFFER - 1] = 0;
346 server_expect_yn = 1; 348 server_expect_yn = 1;
347 break; 349 break;
350 case 'T': /* Content-type */
351 asprintf (&http_content_type, "%s", optarg);
352 break;
348#ifndef HAVE_REGEX_H 353#ifndef HAVE_REGEX_H
349 case 'l': /* linespan */ 354 case 'l': /* linespan */
350 case 'r': /* linespan */ 355 case 'r': /* linespan */
@@ -519,7 +524,11 @@ check_http (void)
519 524
520 /* either send http POST data */ 525 /* either send http POST data */
521 if (http_post_data) { 526 if (http_post_data) {
522 asprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf); 527 if (http_content_type) {
528 asprintf (&buf, "%sContent-Type: %s\r\n", buf, http_content_type);
529 } else {
530 asprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf);
531 }
523 asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, strlen (http_post_data)); 532 asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, strlen (http_post_data));
524 asprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); 533 asprintf (&buf, "%s%s%s", buf, http_post_data, CRLF);
525 } 534 }
@@ -1143,7 +1152,9 @@ certificate expiration times.\n"));
1143 -u, --url=PATH\n\ 1152 -u, --url=PATH\n\
1144 URL to GET or POST (default: /)\n\ 1153 URL to GET or POST (default: /)\n\
1145 -P, --post=STRING\n\ 1154 -P, --post=STRING\n\
1146 URL encoded http POST data\n"), HTTP_EXPECT); 1155 URL encoded http POST data\n\
1156 -T, --content-type=STRING\n\
1157 specify Content-Type header media type when POSTing\n"), HTTP_EXPECT);
1147 1158
1148#ifdef HAVE_REGEX_H 1159#ifdef HAVE_REGEX_H
1149 printf (_("\ 1160 printf (_("\