Implement a new verification routine that doesn't produce false
negatives for HTTP/1.0 connections, and treats 2xx and 3xx HTTP
status returns as successes.

Submitted by: Jacek Prucia <jacek.prucia@7bulls.com>
Reviewed by:  Aaron Bannert


git-svn-id: https://svn.apache.org/repos/asf/httpd/test/trunk/flood@95926 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/flood_profile.c b/flood_profile.c
index 9d65ae0..0801a61 100644
--- a/flood_profile.c
+++ b/flood_profile.c
@@ -270,6 +270,7 @@
 
     /* Verification by OK/200 */
     {"verify_resp",      "verify_200",                   &verify_200},
+    {"verify_resp",      "verify_status_code",           &verify_status_code},
 
     /* Simple Reports */
     {"report_init",      "simple_report_init",           &simple_report_init},
diff --git a/flood_round_robin.c b/flood_round_robin.c
index f20f2f6..0f2cf4b 100644
--- a/flood_round_robin.c
+++ b/flood_round_robin.c
@@ -892,6 +892,25 @@
     return APR_SUCCESS;
 }
 
+apr_status_t verify_status_code(int *verified, profile_t *profile,
+                                request_t *req, response_t *resp)
+{
+    const char delimiter = ' ';
+    char *state, *protocol, *scode;
+
+    protocol = apr_strtok(resp->rbuf, &delimiter, &state);
+    scode = apr_strtok(NULL, &delimiter, &state);
+
+    if (scode[0] == '2' || scode[0] == '3') {
+        *verified = FLOOD_VALID;
+    }
+    else {
+        *verified = FLOOD_INVALID;
+    }
+
+    return APR_SUCCESS;
+}
+
 int round_robin_loop_condition(profile_t *profile)
 {
     round_robin_profile_t *rp;
diff --git a/flood_round_robin.h b/flood_round_robin.h
index e149c1f..0c21e3d 100644
--- a/flood_round_robin.h
+++ b/flood_round_robin.h
@@ -72,6 +72,10 @@
                         profile_t *profile,
                         request_t *req,
                         response_t *resp);
+apr_status_t verify_status_code(int *verified,
+                                profile_t *profile,
+                                request_t *req,
+                                response_t *resp);
 int round_robin_loop_condition(profile_t *profile);
 apr_status_t round_robin_profile_destroy(profile_t *profile);