On Thu, Mar 3, 2016 at 6:10 PM, 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?