diff -Naur haproxy-ss-20090207/include/types/proxy.h haproxy-ss-20090219/include/types/proxy.h
--- haproxy-ss-20090207/include/types/proxy.h	2009-02-06 18:28:13.000000000 +0800
+++ haproxy-ss-20090219/include/types/proxy.h	2009-02-20 17:22:12.000000000 +0800
@@ -104,6 +104,8 @@
 #define PR_O_CONTSTATS	0x10000000	/* continous counters */
 #define PR_O_HTTP_PROXY 0x20000000	/* Enable session to use HTTP proxy operations */
 #define PR_O_DISABLE404 0x40000000      /* Disable a server on a 404 response to a health-check */
+#define PR_O_EXPECT     0x80000000   /* */
+#define PR_O_UNEXPECT   0x60000000   /* */
 /* unused: 0x80000000 */
 
 /* bits for proxy->options2 */
@@ -111,6 +113,10 @@
 #define PR_O2_SPLIC_RTR	0x00000002      /* transfer responses using linux kernel's splice() */
 #define PR_O2_SPLIC_AUT	0x00000004      /* automatically use linux kernel's splice() */
 #define PR_O2_SPLIC_ANY	(PR_O2_SPLIC_REQ|PR_O2_SPLIC_RTR|PR_O2_SPLIC_AUT)
+#define PR_O2_EXPECT_STATUS 	0x00000008
+#define PR_O2_UNEXPECT_STATUS 	0x00000010
+#define PR_O2_EXPECT_STRING 	0x00000020
+#define PR_O2_UNEXPECT_STRING 	0x00000040
 
 /* This structure is used to apply fast weighted round robin on a server group */
 struct fwrr_group {
@@ -253,6 +259,8 @@
 	char *req_add[MAX_NEWHDR], *rsp_add[MAX_NEWHDR]; /* headers to be added */
 	int grace;				/* grace time after stop request */
 	char *check_req;			/* HTTP or SSL request to use for PR_O_HTTP_CHK|PR_O_SSL3_CHK */
+	regex_t *check_status;			/* HTTP Response(status) code */
+	regex_t *check_string;			/* HTTP Reponse content */	
 	int check_len;				/* Length of the HTTP or SSL3 request */
 	struct chunk errmsg[HTTP_ERR_SIZE];	/* default or customized error messages for known errors */
 	int uuid;				/* universally unique proxy ID, used for SNMP */
diff -Naur haproxy-ss-20090207/src/cfgparse.c haproxy-ss-20090219/src/cfgparse.c
--- haproxy-ss-20090207/src/cfgparse.c	2009-02-06 18:28:13.000000000 +0800
+++ haproxy-ss-20090219/src/cfgparse.c	2009-02-20 17:42:13.000000000 +0800
@@ -1662,12 +1662,89 @@
 		if (strcmp(args[1], "disable-on-404") == 0) {
 			/* enable a graceful server shutdown on an HTTP 404 response */
 			curproxy->options |= PR_O_DISABLE404;
-		}
+		} 
+		/* finalbsd(start) */
+		else if(strcmp(args[1], "expect") == 0) {
+			if(strcmp(args[2], "status") ==0) {
+				if(*(args[3]) == 0) {
+					Alert("parsing [%s:%d] : '%s %s %s' expects  <regex> as an argument.\n", file, linenum, args[0], args[1], args[2]);
+					return -1;
+				}
+				free(curproxy->check_status);
+		                curproxy->check_status = calloc(1, sizeof(regex_t));
+       		                if (regcomp(curproxy->check_status, args[3], REG_EXTENDED) != 0) {
+                       	 		Alert("parsing [%s:%d] : bad regular expression '%s'.\n", file, linenum, args[0]);
+                        		return -1;
+                		}	
+
+				curproxy->options  |= PR_O_EXPECT;
+				curproxy->options2 |= PR_O2_EXPECT_STATUS;
+			}
+			else if(strcmp(args[2], "string") == 0) {
+                                if(*(args[3]) == 0) {
+					Alert("parsing [%s:%d] : '%s %s %s' expects  <regex> as an argument.\n", file, linenum, args[0], args[1], args[2]);
+                                        return -1;
+                                }
+                                free(curproxy->check_string);
+                                curproxy->check_string = calloc(1, sizeof(regex_t));
+                                if (regcomp(curproxy->check_string, args[3], REG_EXTENDED) != 0) {
+                                        Alert("parsing [%s:%d] : bad regular expression '%s'.\n", file, linenum, args[0]);
+                                        return -1;
+                                }
+
+				curproxy->options  |= PR_O_EXPECT;
+                                curproxy->options2 |= PR_O2_EXPECT_STRING;
+        
+			} 
+			else if(strcmp(args[2], "!") == 0){
+
+				if(strcmp(args[3], "status") == 0) {
+                                	if(*(args[4]) == 0) {
+						Alert("parsing [%s:%d] : '%s %s %s %s' expects  <regex> as an argument.\n", 
+							file, linenum, args[0], args[1], args[2], args[3]);
+						return -1;
+					}
+					free(curproxy->check_status);
+		                	curproxy->check_status = calloc(1, sizeof(regex_t));
+       		                	if (regcomp(curproxy->check_status, args[4], REG_EXTENDED) != 0) {
+                       				Alert("parsing [%s:%d] : bad regular expression '%s'.\n", file, linenum, args[0]);
+                        			 return -1;
+                			}	
+					curproxy->options  |= PR_O_UNEXPECT;
+					curproxy->options2 |= PR_O2_EXPECT_STATUS;
+				} 
+				else if(strcmp(args[3], "string") == 0) {
+                                        if(*(args[4]) == 0) {
+                                                Alert("parsing [%s:%d] : '%s %s %s %s' expects  <regex> as an argument.\n",
+                                                     file, linenum, args[0], args[1], args[2], args[3]);
+                                                return -1;
+                                        }
+                                        free(curproxy->check_string);
+                                        curproxy->check_string = calloc(1, sizeof(regex_t));
+                                        if (regcomp(curproxy->check_string, args[4], REG_EXTENDED) != 0) {
+                                                Alert("parsing [%s:%d] : bad regular expression '%s'.\n", file, linenum, args[0]);
+                                                return -1;
+                                        }
+					curproxy->options  |= PR_O_UNEXPECT;
+                                        curproxy->options2 |= PR_O2_EXPECT_STRING;
+				} 
+				else {
+					Alert("parsing [%s:%d] : '%s %s %s' only supports  status|string'.\n", 
+						file, linenum, args[0], args[1], args[2]);
+					return -1;
+				}
+			} 
+			else {
+				Alert("parsing [%s:%d] : '%s %s' only supports (!) status|string'.\n", file, linenum, args[0], args[1]);
+				return -1;
+			} 
+		} 
 		else {
-			Alert("parsing [%s:%d] : '%s' only supports 'disable-on-404'.\n", file, linenum, args[0]);
+			Alert("parsing [%s:%d] : '%s' only supports 'disable-on-404', 'expect' .\n", file, linenum, args[0]);
 			return -1;
 		}
 	}
+		/* finalbsd(end) */
 	else if (!strcmp(args[0], "monitor")) {
 		if (curproxy == &defproxy) {
 			Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
diff -Naur haproxy-ss-20090207/src/checks.c haproxy-ss-20090219/src/checks.c
--- haproxy-ss-20090207/src/checks.c	2009-02-06 18:28:13.000000000 +0800
+++ haproxy-ss-20090219/src/checks.c	2009-02-20 17:35:30.000000000 +0800
@@ -477,8 +477,67 @@
 			goto out_wakeup;
 		}
 
+		/* finalbsd (start) */
+		if(s->proxy->options & PR_O_EXPECT) {
+			if(s->proxy->options2 & PR_O2_EXPECT_STATUS) {
+				char  status_code[4]="000";
+				memcpy(status_code, &trash[9], 3);
+				if(regexec(s->proxy->check_status, status_code, MAX_MATCH, pmatch, 0) ==0)
+					s->result |= SRV_CHK_RUNNING;
+				else 
+					s->result |= SRV_CHK_ERROR;
+			} else if(s->proxy->options2 & PR_O2_EXPECT_STRING) {
+                                char content[BUFSIZE];
+                                memcpy(content, trash, sizeof(trash));
+                                char *contentlen=strstr(content, "Content-Length");
+                                char *conlen;
+                                contentlen+=16;
+                                if ( (conlen=strstr(contentlen,"\n")) != NULL )
+                                        *conlen = '\0';
+
+                                char *contentptr=NULL;
+                                if((contentptr = strstr(trash, "\r\n\r\n")) != NULL) {
+                                        contentptr += atoi(contentlen);
+                                        contentptr[4] ='\0';
+                                        if(regexec(s->proxy->check_string, contentptr, MAX_MATCH, pmatch, 0) ==0)
+                                                s->result |= SRV_CHK_RUNNING;
+                                        else
+                                                s->result |= SRV_CHK_ERROR;
+                                }
+			}
+		} 
+		else if(s->proxy->options & PR_O_UNEXPECT) {
+			if(s->proxy->options2 & PR_O2_EXPECT_STATUS) {
+				char  status_code[4]="000";
+				memcpy(status_code, &trash[9], 3);
+				if(regexec(s->proxy->check_status, status_code, MAX_MATCH, pmatch, 0) ==0)
+					s->result |= SRV_CHK_ERROR;
+				else 
+					s->result |= SRV_CHK_RUNNING;
+			} else if(s->proxy->options2 & PR_O2_EXPECT_STRING) {
+                                char content[BUFSIZE];
+                                memcpy(content, trash, sizeof(trash));
+                                char *contentlen=strstr(content, "Content-Length");
+                                char *conlen;
+                                contentlen+=16;
+                                if ( (conlen=strstr(contentlen,"\n")) != NULL )
+                                        *conlen = '\0';
+
+                                char *contentptr=NULL;
+                                if((contentptr = strstr(trash, "\r\n\r\n")) != NULL) {
+                                        contentptr += atoi(contentlen);
+                                        contentptr[4] ='\0';
+                                        if(regexec(s->proxy->check_string, contentptr, MAX_MATCH, pmatch, 0) ==0)
+                                                s->result |= SRV_CHK_ERROR;
+                                        else
+                                                s->result |= SRV_CHK_RUNNING;
+                                }
+			}
+
+		}
+/* finalbsd(end) */
 		/* check the reply : HTTP/1.X 2xx and 3xx are OK */
-		if (trash[9] == '2' || trash[9] == '3')
+		else if (trash[9] == '2' || trash[9] == '3')
 			s->result |= SRV_CHK_RUNNING;
 		else if ((s->proxy->options & PR_O_DISABLE404) &&
 			 (s->state & SRV_RUNNING) &&
