From 15e5ea295c05f0e609de4c744ffacf4440dfee9b Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Fri, 20 Feb 2004 03:21:40 +0000 Subject: [PATCH] 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 --- plugins/check_http.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/check_http.c b/plugins/check_http.c index 8e45e88..afd75d3 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -111,6 +111,7 @@ int redir_depth = 0; int max_depth = 15; char *http_method; char *http_post_data; +char *http_content_type; char buffer[MAX_INPUT_BUFFER]; int process_arguments (int, char **); @@ -207,6 +208,7 @@ process_arguments (int argc, char **argv) {"linespan", no_argument, 0, 'l'}, {"onredirect", required_argument, 0, 'f'}, {"certificate", required_argument, 0, 'C'}, + {"content-type", required_argument, 0, 'T'}, {"min", required_argument, 0, 'm'}, {"use-ipv4", no_argument, 0, '4'}, {"use-ipv6", no_argument, 0, '6'}, @@ -345,6 +347,9 @@ process_arguments (int argc, char **argv) server_expect[MAX_INPUT_BUFFER - 1] = 0; server_expect_yn = 1; break; + case 'T': /* Content-type */ + asprintf (&http_content_type, "%s", optarg); + break; #ifndef HAVE_REGEX_H case 'l': /* linespan */ case 'r': /* linespan */ @@ -519,7 +524,11 @@ check_http (void) /* either send http POST data */ if (http_post_data) { - asprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf); + if (http_content_type) { + asprintf (&buf, "%sContent-Type: %s\r\n", buf, http_content_type); + } else { + asprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf); + } asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, strlen (http_post_data)); asprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); } @@ -1143,7 +1152,9 @@ certificate expiration times.\n")); -u, --url=PATH\n\ URL to GET or POST (default: /)\n\ -P, --post=STRING\n\ - URL encoded http POST data\n"), HTTP_EXPECT); + URL encoded http POST data\n\ + -T, --content-type=STRING\n\ + specify Content-Type header media type when POSTing\n"), HTTP_EXPECT); #ifdef HAVE_REGEX_H printf (_("\ -- 2.30.2