[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-test-dev
Subject:    RE: need a custom verify_resp function
From:       "Sergey Ten" <sergey () sourcelabs ! com>
Date:       2005-05-12 18:37:28
Message-ID: 200505121832.j4CIWmXW026081 () sourcelabs ! sourcelabs ! com
[Download RAW message or body]

Thank you for your help, Jacek.

As it was suggested, I replaced 'waitfor' with 'acceptcode'. Regarding
removing "global waitfor (flood_round_robin.c)". I think the diff caused
some confusion: that waitfor was a field in the url_t type, and it can't be
removed. I hope the new diff I am attaching (prepared using cvs diff -u)
will be more helpful.

Best regards,
Sergey Ten
SourceLabs

> -----Original Message-----
> From: Jacek Prucia [mailto:jacek.prucia@acn.waw.pl]
> Sent: Wednesday, May 11, 2005 3:22 PM
> To: test-dev@httpd.apache.org
> Subject: Re: need a custom verify_resp function
> 
> 
> > Hello all,
> >
> > I have a change which implements a generic function comparing returned
> code
> > against specified as an attribute of the url. The diff is enclosed. Is
> there
> > a document how to check-in into the flood source tree?
> 
> Yup. It is actually for httpd-dev folks, but most rules apply anyway:
> 
> http://httpd.apache.org/dev/patches.html
> 
> Before you prepare unified diff (see document above), I'd suggest
> removing global waitfor (flood_round_robin.c). It doesn't seem to be
> used anywhere else. Also please consider using 'acceptcode' in favor of
> 'waitfor'. Technically speaking, flood doesn't wait for anything. It
> just chceks return code, and moves forward. Besides that looks OK. If
> nobody has any objections, I'll commit it as soon as I get my
> development machine ready.
> 
> regards,
> --
> Jacek Prucia

["diff.txt" (text/plain)]

Index: config.h.in
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/config.h.in,v
retrieving revision 1.32
diff -u -r1.32 config.h.in
--- config.h.in	3 Aug 2004 10:22:14 -0000	1.32
+++ config.h.in	12 May 2005 18:15:54 -0000
@@ -37,6 +37,7 @@
 #define XML_URLLIST_USER "user"
 #define XML_URLLIST_PASSWORD "password"
 #define XML_URLLIST_NAME "name"
+#define XML_URLLIST_ACCEPTCODE "acceptcode"
 #define XML_PROFILE "profile"
 #define XML_PROFILE_COUNT "count"
 #define XML_PROFILE_USEURLLIST "useurllist"
Index: flood_profile.c
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/flood_profile.c,v
retrieving revision 1.27
diff -u -r1.27 flood_profile.c
--- flood_profile.c	9 Feb 2004 08:12:56 -0000	1.27
+++ flood_profile.c	12 May 2005 18:15:54 -0000
@@ -254,6 +254,9 @@
     {"report_stats",     "relative_times_report_stats",  &relative_times_report_stats},
     {"destroy_report",   "relative_times_destroy_report",&relative_times_destroy_report},
 
+    /* Verification by a given code */
+    {"verify_resp",      "verify_returned_code",         &verify_returned_code},
+
     {NULL} /* sentinel value */
 };
 
Index: flood_round_robin.c
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/flood_round_robin.c,v
retrieving revision 1.42
diff -u -r1.42 flood_round_robin.c
--- flood_round_robin.c	3 Aug 2004 10:22:14 -0000	1.42
+++ flood_round_robin.c	12 May 2005 18:15:54 -0000
@@ -84,6 +84,7 @@
     int responselen;
     char *user;
     char *password;
+    char *acceptcode;
 } url_t;
 
 typedef struct cookie_t {
@@ -497,6 +498,11 @@
                                  FLOOD_STRLEN_MAX) == 0) {
                 url->password = (char*)attr->value;
             }
+            else if (strncasecmp(attr->name,
+                                 XML_URLLIST_WAITFOR,
+                                 FLOOD_STRLEN_MAX) == 0) {
+                url->acceptcode = (char*)attr->value;
+            }
             attr = attr->next;
         }
     }
@@ -1128,6 +1134,29 @@
     return APR_SUCCESS;
 }
 
+apr_status_t verify_returned_code(int *verified, profile_t *profile, request_t *req, response_t *resp)
+{
+    int res = memcmp(resp->rbuf, "HTTP/1.1 2", 10);
+    round_robin_profile_t *rp = (round_robin_profile_t*)profile;
+    char *acceptcode = rp->url[rp->current_url].acceptcode;
+
+    if (!res)
+        *verified = FLOOD_VALID;
+    else if (NULL != acceptcode)
+    {
+        if (memcmp(resp->rbuf + 9, acceptcode, 3) == 0) /* Compare against acceptcode. */
+            *verified = FLOOD_VALID;
+        else
+            *verified = FLOOD_INVALID;
+    }
+    else if (memcmp(resp->rbuf + 9, "3", 1) == 0) /* Accept 3xx as okay. */
+        *verified = FLOOD_VALID;
+    else
+        *verified = FLOOD_INVALID;
+
+    return APR_SUCCESS;
+}
+
 int round_robin_loop_condition(profile_t *profile)
 {
     round_robin_profile_t *rp;
Index: flood_round_robin.h
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/flood_round_robin.h,v
retrieving revision 1.8
diff -u -r1.8 flood_round_robin.h
--- flood_round_robin.h	9 Feb 2004 08:12:56 -0000	1.8
+++ flood_round_robin.h	12 May 2005 18:15:54 -0000
@@ -39,5 +39,9 @@
                                 response_t *resp);
 int round_robin_loop_condition(profile_t *profile);
 apr_status_t round_robin_profile_destroy(profile_t *profile);
+apr_status_t verify_returned_code(int *verified,
+                        profile_t *profile,
+                        request_t *req,
+                        response_t *resp);
 
 #endif /* __FLOOD_ROUND_ROBIN_H */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic