Discussion:
need a custom verify_resp function
Sergey Ten
2005-05-03 17:36:02 UTC
Permalink
Hello all,



I wonder if someone has already implemented a custom verify_resp function
which checks if the return code equals to a given (can be different from
200)?



Currently flood treats any code returned by http request and different from
200 and 3xx as indication of failure. In our testing we would like to send a
request which is expected to return a specific failure code (e.g. 401), and
treat it as a success if and only if the expected code is returned.

I would like to make sure that this function has not been already
implemented before start coding myself.



Thanks,

Sergey



Sergey Ten

SourceLabs Inc.

(206)322-0099 x108
Jacek Prucia
2005-05-04 22:28:01 UTC
Permalink
[...]
Post by Sergey Ten
I wonder if someone has already implemented a custom verify_resp function
which checks if the return code equals to a given (can be different from
200)?
Nope. We have only 2 verify_resp functions, and basically they do the
same thing.
Post by Sergey Ten
Currently flood treats any code returned by http request and different from
200 and 3xx as indication of failure. In our testing we would like to send a
request which is expected to return a specific failure code (e.g. 401), and
treat it as a success if and only if the expected code is returned.
I would like to make sure that this function has not been already
implemented before start coding myself.
There is no such function, so you can go on and implement whatever you
need. However, it seems a bit weird, that such functionality requires
implementing a function. An generic function, that would use a pattern
to decide if a request succeded or not, would be great :)

regards,
--
Jacek Prucia
Sergey Ten
2005-05-10 17:54:08 UTC
Permalink
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?

Best regards,
Sergey Ten,
SourceLabs
Dependable Open Source Systems


Index: config.h.in
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/config.h.in,v
retrieving revision 1.32
diff -r1.32 config.h.in
39a40
#define XML_URLLIST_WAITFOR "waitfor"
Index: flood_profile.c
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/flood_profile.c,v
retrieving revision 1.27
diff -r1.27 flood_profile.c
256a257,259
/* Verification by a given code */
{"verify_resp", "verify_returned_code",
&verify_returned_code},
Index: flood_round_robin.c
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/flood_round_robin.c,v
retrieving revision 1.42
diff -r1.42 flood_round_robin.c
86a87,89
/* WaitFor code */
char *waitfor;
499a503,507
else if (strncasecmp(attr->name,
XML_URLLIST_WAITFOR,
FLOOD_STRLEN_MAX) == 0) {
url->waitfor = (char*)attr->value;
}
1130a1139,1161
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 *waitfor = rp->url[rp->current_url].waitfor;
if (!res)
*verified = FLOOD_VALID;
else if (NULL != waitfor)
{
if (memcmp(resp->rbuf + 9, waitfor, 3) == 0) /* Compare against
waitfor code. */
*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;
}
Index: flood_round_robin.h
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/flood_round_robin.h,v
retrieving revision 1.8
diff -r1.8 flood_round_robin.h
41a42,45
apr_status_t verify_returned_code(int *verified,
profile_t *profile,
request_t *req,
response_t *resp);
-----Original Message-----
Sent: Wednesday, May 04, 2005 3:28 PM
Subject: Re: need a custom verify_resp function
[...]
Post by Sergey Ten
I wonder if someone has already implemented a custom verify_resp
function
Post by Sergey Ten
which checks if the return code equals to a given (can be different from
200)?
Nope. We have only 2 verify_resp functions, and basically they do the
same thing.
Post by Sergey Ten
Currently flood treats any code returned by http request and different
from
Post by Sergey Ten
200 and 3xx as indication of failure. In our testing we would like to
send a
Post by Sergey Ten
request which is expected to return a specific failure code (e.g. 401),
and
Post by Sergey Ten
treat it as a success if and only if the expected code is returned.
I would like to make sure that this function has not been already
implemented before start coding myself.
There is no such function, so you can go on and implement whatever you
need. However, it seems a bit weird, that such functionality requires
implementing a function. An generic function, that would use a pattern
to decide if a request succeded or not, would be great :)
regards,
--
Jacek Prucia
Jacek Prucia
2005-05-11 22:22:12 UTC
Permalink
Post by Sergey Ten
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
Sergey Ten
2005-05-12 18:37:28 UTC
Permalink
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-----
Sent: Wednesday, May 11, 2005 3:22 PM
Subject: Re: need a custom verify_resp function
Post by Sergey Ten
Hello all,
I have a change which implements a generic function comparing returned
code
Post by Sergey Ten
against specified as an attribute of the url. The diff is enclosed. Is
there
Post by Sergey Ten
a document how to check-in into the flood source tree?
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
Loading...