diff -ruN nagiosplug-save/plugins/check_http.c nagiosplug/plugins/check_http.c
--- nagiosplug-save/plugins/check_http.c	2004-03-03 12:33:15.000000000 +0000
+++ nagiosplug/plugins/check_http.c	2004-03-28 19:56:12.000000000 +0100
@@ -94,6 +94,7 @@
 char *user_agent;
 int server_url_length;
 int server_expect_yn = 0;
+char *cookies=NULL;
 char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT;
 char string_expect[MAX_INPUT_BUFFER] = "";
 double warning_time = 0;
@@ -104,6 +105,7 @@
 int display_html = FALSE;
 int onredirect = STATE_OK;
 int use_ssl = FALSE;
+int keepalive = FALSE;
 int verbose = FALSE;
 int sd;
 int min_page_len = 0;
@@ -206,6 +208,7 @@
 		{"ereg", required_argument, 0, 'r'},
 		{"eregi", required_argument, 0, 'R'},
  		{"linespan", no_argument, 0, 'l'},
+ 		{"keepalive", no_argument, 0, 'k'},
 		{"onredirect", required_argument, 0, 'f'},
 		{"certificate", required_argument, 0, 'C'},
 		{"content-type", required_argument, 0, 'T'},
@@ -232,7 +235,7 @@
 	}
 
 	while (1) {
-		c = getopt_long (argc, argv, "Vvh46t:c:w:H:P:T:I:a:e:p:s:R:r:u:f:C:nlLSm:", longopts, &option);
+		c = getopt_long (argc, argv, "Vvh46t:c:w:H:P:T:I:a:e:p:s:R:r:u:f:C:nlkLSm:", longopts, &option);
 		if (c == -1 || c == EOF)
 			break;
 
@@ -383,6 +386,9 @@
 			usage (_("IPv6 support not available\n"));
 #endif
 			break;
+		case 'k': /* Keep-Alive */
+		        keepalive = TRUE;
+			break;
 		case 'v': /* verbose */
 			verbose = TRUE;
 			break;
@@ -480,7 +486,7 @@
 	char *pos;
 	long microsec;
 	double elapsed_time;
-	int page_len = 0;
+	int page_len;
 #ifdef HAVE_SSL
 	int sslerr;
 #endif
@@ -516,6 +522,16 @@
 	if (host_name)
 		asprintf (&buf, "%sHost: %s\r\n", buf, host_name);
 
+	/* send Collected Cookies */
+	if(cookies)
+	{
+		asprintf (&buf, "%s%s\r\n", buf,cookies);
+	}
+
+	/* send "Connection: Keep-Alive" if need */
+	if(keepalive)
+		asprintf (&buf, "%sConnection: Keep-Alive\r\n", buf); 
+
 	/* optionally send the authentication info */
 	if (strlen(user_auth)) {
 		auth = base64 (user_auth, strlen (user_auth));
@@ -549,6 +565,9 @@
 	}
 	else {
 #endif
+	if (verbose)
+		printf ("**** REQUEST ****\n%s\n", buf);
+
 		send (sd, buf, strlen (buf), 0);
 #ifdef HAVE_SSL
 	}
@@ -772,6 +791,10 @@
 #define URI_HOST "%[-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]"
 #define URI_PORT ":%[0123456789]"
 #define URI_PATH "%[-_.!~*'();/?:@&=+$,%#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]"
+#define HDR_SETCOOKIE "%*[Ss]%*[Ee]%*[Tt]%*[-]%*[Cc]%*[Oo]%*[Kk]%*[Ii]%*[Ee]: "
+#define COOKIE_BODY "%[/a-zA-Z0-9._-=@,: ]"
+#define COOKIE_PATH ";%[/a-zA-Z0-9._-=@,: ]"
+#define COOKIE_DATE COOKIE_PATH
 #define HD1 URI_HTTP URI_HOST URI_PORT URI_PATH
 #define HD2 URI_HTTP URI_HOST URI_PATH
 #define HD3 URI_HTTP URI_HOST URI_PORT
@@ -788,6 +811,13 @@
 	char *addr;
 	char port[6];
 	char *url;
+	char *cpos = "";
+	char cookie_body[255];
+	char cookie_path[255];
+	char cookie_date[255];
+	struct tm tm;
+	char date[255],rest[255];
+	int page_len = 0;
 
 	addr = malloc (MAX_IPV4_HOSTLENGTH + 1);
 	if (addr == NULL)
@@ -797,6 +827,42 @@
 	if (url == NULL)
 		die (STATE_UNKNOWN, _("ERROR: could not allocate url\n"));
 
+	cpos = pos;
+	cookies = NULL;
+	while (*cpos) {
+	        cookie_date[0] = '\0';
+		if (sscanf (cpos, HDR_SETCOOKIE COOKIE_BODY COOKIE_PATH COOKIE_DATE,
+			   cookie_body, cookie_path, cookie_date)) {
+		  if (verbose)
+		          printf ("Cookie parameters: body=%s path=%s date=%s\n",
+				  cookie_body, cookie_path, cookie_date);
+		  if (strlen(cookie_date) > 1) {
+		          sscanf (cookie_date, "%*[Ee]%*[Xx]%*[Pp]%*[Ii]%*[Rr]%*[Ee]%*[Ss]=%*s %s %s %*s",
+				  date, rest);
+			  strcat (date, " ");
+			  strcat (date, rest);
+			  strptime(date, "%d-%b-%Y %T", &tm);
+			  if (verbose)
+			          printf ("Cookie Date %d-%d-%d Time  %d:%d:%d\n",
+					  tm.tm_mday, tm.tm_mon, tm.tm_year,
+					  tm.tm_hour, tm.tm_min, tm.tm_sec);
+			  if (mktime(&tm) < time(0)) {
+			          if (verbose)
+				          printf ("Ignoring cookie since it has expired\n");
+				  cpos += (size_t) strcspn (cpos, "\r\n");
+				  cpos += (size_t) strspn (cpos, "\r\n");
+				  continue;
+			  }
+		  }
+		  if (cookies)
+		          asprintf (&cookies, "%s;%s", cookies, cookie_body);
+		  else
+		          asprintf (&cookies, "Cookie: %s", cookie_body);
+		}
+		cpos += (size_t) strcspn (cpos, "\r\n");
+		cpos += (size_t) strspn (cpos, "\r\n");
+	}
+
 	while (pos) {
 
 		if (sscanf (pos, "%[Ll]%*[Oo]%*[Cc]%*[Aa]%*[Tt]%*[Ii]%*[Oo]%*[Nn]:%n", xx, &i) < 1) {
@@ -1173,6 +1239,8 @@
    Wrap output in HTML link (obsoleted by urlize)\n\
  -f, --onredirect=<ok|warning|critical|follow>\n\
    How to handle redirected pages\n\
+ -k, --keepalive\n\
+   Use Keep-Alive header in every request\n\
  -m, --min=INTEGER\n\
    Minimum page size required (bytes)\n"));
 
@@ -1221,10 +1289,10 @@
 print_usage (void)
 {
 	printf (_("\
-Usage: %s (-H <vhost> | -I <IP-address>) [-u <uri>] [-p <port>]\n\
-  [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\
-  [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\
-  [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\
+Usage: %s (-H <vhost> | -I <IP-address>) [-u <uri>] [-p <port>]\
+  [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\
+  [-a auth] [-f <ok | warn | critical | follow>] [-e <expect>]\
+  [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\
   [-P string] [-m min_pg_size] [-4|-6]\n"), progname);
 	printf (_(UT_HLP_VRS), progname, progname);
 }
