[Nagiosplug-checkins] CVS: nagiosplug/plugins check_http.c,1.61,1.62

Ton Voon tonvoon at users.sourceforge.net
Thu Nov 18 16:14:01 CET 2004


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25703

Modified Files:
	check_http.c 
Log Message:
Options for User Agent string and extra headers (Ibere Tizio)


Index: check_http.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_http.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -C2 -r1.61 -r1.62
*** check_http.c	17 Nov 2004 23:22:54 -0000	1.61
--- check_http.c	19 Nov 2004 00:12:55 -0000	1.62
***************
*** 27,30 ****
--- 27,32 ----
  #include "utils.h"
  
+ #define INPUT_DELIMITER ";"
+ 
  #define HTTP_EXPECT "HTTP/1."
  enum {
***************
*** 105,108 ****
--- 107,111 ----
  char user_auth[MAX_INPUT_BUFFER] = "";
  int display_html = FALSE;
+ char *http_opt_headers;
  int onredirect = STATE_OK;
  int use_ssl = FALSE;
***************
*** 212,215 ****
--- 215,220 ----
  		{"onredirect", required_argument, 0, 'f'},
  		{"certificate", required_argument, 0, 'C'},
+ 		{"useragent", required_argument, 0, 'A'},
+ 		{"header", required_argument, 0, 'k'},
  		{"no-body", no_argument, 0, 'N'},
  		{"max-age", required_argument, 0, 'M'},
***************
*** 238,242 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "Vvh46t:c:w:H:P:T:I:a:e:p:s:R:r:u:f:C:nlLSm:M:N", longopts, &option);
  		if (c == -1 || c == EOF)
  			break;
--- 243,247 ----
  
  	while (1) {
! 		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);
  		if (c == -1 || c == EOF)
  			break;
***************
*** 276,279 ****
--- 281,290 ----
  			}
  			break;
+ 		case 'A': /* User Agent String */
+ 			asprintf (&user_agent, "User-Agent: %s", optarg);
+ 			break;
+ 		case 'k': /* Additional headers */
+ 			asprintf (&http_opt_headers, "%s", optarg);
+ 			break;
  		case 'L': /* show html link */
  			display_html = TRUE;
***************
*** 742,745 ****
--- 753,762 ----
  		asprintf (&buf, "%sHost: %s\r\n", buf, host_name);
  
+ 	/* optionally send any other header tag */
+ 	if (http_opt_headers) {
+ 		for ((pos = strtok(http_opt_headers, INPUT_DELIMITER)); pos; (pos = strtok(NULL, INPUT_DELIMITER)))
+ 			asprintf (&buf, "%s%s\r\n", buf, pos);
+ 	}
+ 
  	/* optionally send the authentication info */
  	if (strlen(user_auth)) {
***************
*** 1411,1414 ****
--- 1428,1435 ----
   -a, --authorization=AUTH_PAIR\n\
     Username:password on sites with basic authentication\n\
+  -A, --useragent=STRING\n\
+    String to be sent in http header as \"User Agent\"\n\
+  -k, --header=STRING\n\
+    Any other tags to be sent in http header, separated by semicolon\n\
   -L, --link=URL\n\
     Wrap output in HTML link (obsoleted by urlize)\n\
***************
*** 1467,1471 ****
    [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\
    [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\
!   [-P string] [-m min_pg_size] [-4|-6] [-N] [-M <age>]\n"), progname);
  	printf (_(UT_HLP_VRS), progname, progname);
  }
--- 1488,1493 ----
    [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\
    [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\
!   [-P string] [-m min_pg_size] [-4|-6] [-N] [-M <age>] [-A string]\n\
!   [-k string]\n"), progname);
  	printf (_(UT_HLP_VRS), progname, progname);
  }





More information about the Commits mailing list