You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by William A Rowe Jr <wr...@rowe-clan.net> on 2016/05/24 19:01:10 UTC
Re: svn commit: r1733537 - /httpd/httpd/trunk/support/ab.c
On Thu, Mar 3, 2016 at 6:10 PM, <yl...@apache.org> wrote:
> Author: ylavic
> Date: Fri Mar 4 00:10:10 2016
> New Revision: 1733537
>
> URL: http://svn.apache.org/viewvc?rev=1733537&view=rev
> Log:
> ab: Use caseless matching for HTTP tokens (e.g. content-length).
> PR 59111.
>
> Modified:
> httpd/httpd/trunk/support/ab.c
>
> Modified: httpd/httpd/trunk/support/ab.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/support/ab.c?rev=1733537&r1=1733536&r2=1733537&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/support/ab.c (original)
> +++ httpd/httpd/trunk/support/ab.c Fri Mar 4 00:10:10 2016
> @@ -426,6 +426,41 @@ static char *xstrdup(const char *s)
> return ret;
> }
>
> +/*
> + * Similar to standard strstr() but we ignore case in this version.
> + * Copied from ap_strcasestr().
> + */
> +static char *xstrcasestr(const char *s1, const char *s2)
> +{
> + char *p1, *p2;
> + if (*s2 == '\0') {
> + /* an empty s2 */
> + return((char *)s1);
> + }
> + while(1) {
> + for ( ; (*s1 != '\0') && (apr_tolower(*s1) != apr_tolower(*s2));
> s1++);
> + if (*s1 == '\0') {
> + return(NULL);
> + }
> + /* found first character of s2, see if the rest matches */
> + p1 = (char *)s1;
> + p2 = (char *)s2;
> + for (++p1, ++p2; apr_tolower(*p1) == apr_tolower(*p2); ++p1,
> ++p2) {
> + if (*p1 == '\0') {
> + /* both strings ended together */
> + return((char *)s1);
> + }
> + }
> + if (*p2 == '\0') {
> + /* second string ended, a match */
> + break;
> + }
> + /* didn't find a match here, try starting at next character in s1
> */
> + s1++;
> + }
> + return((char *)s1);
> +}
> +
> /* pool abort function */
> static int abort_on_oom(int retcode)
> {
>
Two thoughts. It seems this is a good candidate for APR 1.6
apr_cstr_casestr?
Second thought - it seems like the implement locally -> push to apr model
is good for as far as it gets us, but we don't want our httpd users to be in
a rat race to chase new apr[-util] behavior unless they are chasing a new
httpd optional module or feature.
What if we were to refactor some of server/util*.c into a localized
ap-httpd.so
library that could be consumed by httpd core, as well as our support
utilities
and third parties who want our very http-specific functions that are simply
not
good fits for apr?
Re: svn commit: r1733537 - /httpd/httpd/trunk/support/ab.c
Posted by Yann Ylavic <yl...@gmail.com>.
On Tue, May 24, 2016 at 9:01 PM, William A Rowe Jr <wr...@rowe-clan.net> wrote:
>>
>> +/*
>> + * Similar to standard strstr() but we ignore case in this version.
>> + * Copied from ap_strcasestr().
>> + */
>> +static char *xstrcasestr(const char *s1, const char *s2)
>> +{
[]
>> +}
>
> Two thoughts. It seems this is a good candidate for APR 1.6
> apr_cstr_casestr?
+1
>
> Second thought - it seems like the implement locally -> push to apr model
> is good for as far as it gets us, but we don't want our httpd users to be in
> a rat race to chase new apr[-util] behavior unless they are chasing a new
> httpd optional module or feature.
>
> What if we were to refactor some of server/util*.c into a localized
> ap-httpd.so
> library that could be consumed by httpd core, as well as our support
> utilities
> and third parties who want our very http-specific functions that are simply
> not
> good fits for apr?
+1
We'd probably need to be able to update ap-httpd for the needs of the
next httpd release (with the same API/ABI-changes constraints for
both, i.e. httpd's), and hence ship them together.
That would also help implementing useful things to/in both httpd and
APR (as trunk/next proposal), and use them immediatly in httpd without
requiring APR next or putting stub in httpd core (the stub would be in
ap-httpd, eg. like the ap_cstr_casecmp we are currently discussing,
and once httpd requires the next APR version for other reasons, this
stub would become a single #define).
Regards,
Yann.