From 29843dc73fc32f21223d111d0fc3c3ff77160316 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Mon, 23 Nov 2015 12:33:09 +0000 Subject: [PATCH] Use new ap_casecmpstr[n]() functions where appropriate (not exhaustive). [Reverted by r1715869] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1715789 13f79535-47bb-0310-9956-ffa450edef68 --- modules/cache/cache_util.c | 103 ++++++++++++----------------- modules/filters/mod_deflate.c | 18 ++--- modules/filters/mod_include.c | 54 +++++++-------- modules/filters/mod_proxy_html.c | 12 ++-- modules/generators/mod_autoindex.c | 4 +- modules/generators/mod_cgi.c | 2 +- modules/generators/mod_cgid.c | 2 +- modules/http/byterange_filter.c | 4 +- modules/http/http_filters.c | 6 +- modules/http2/h2_from_h1.c | 2 +- modules/loggers/mod_log_config.c | 26 ++++---- modules/mappers/mod_rewrite.c | 50 +++++++------- modules/metadata/mod_cern_meta.c | 4 +- modules/metadata/mod_headers.c | 6 +- modules/proxy/ajp_header.c | 12 ++-- modules/proxy/mod_proxy.c | 6 +- modules/proxy/mod_proxy_ajp.c | 6 +- modules/proxy/mod_proxy_balancer.c | 4 +- modules/proxy/mod_proxy_fcgi.c | 4 +- modules/proxy/mod_proxy_fdpass.c | 4 +- modules/proxy/mod_proxy_ftp.c | 10 +-- modules/proxy/mod_proxy_http.c | 10 +-- modules/proxy/mod_proxy_scgi.c | 6 +- modules/proxy/mod_proxy_wstunnel.c | 10 +-- modules/proxy/mod_serf.c | 26 ++++---- modules/proxy/proxy_util.c | 36 +++++----- modules/slotmem/mod_slotmem_shm.c | 2 +- modules/test/mod_policy.c | 43 ++---------- server/mpm_unix.c | 4 +- server/protocol.c | 12 ++-- server/util.c | 6 +- server/util_expr_eval.c | 10 +-- server/util_script.c | 26 ++++---- 33 files changed, 241 insertions(+), 289 deletions(-) diff --git a/modules/cache/cache_util.c b/modules/cache/cache_util.c index b29d2eee4a..343ca003ea 100644 --- a/modules/cache/cache_util.c +++ b/modules/cache/cache_util.c @@ -594,7 +594,12 @@ int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache, } if ((agestr = apr_table_get(h->resp_hdrs, "Age"))) { - age_c = apr_atoi64(agestr); + char *endp; + apr_off_t offt; + if (!apr_strtoff(&offt, agestr, &endp, 10) + && endp > agestr && !*endp) { + age_c = offt; + } } /* calculate age of object */ @@ -994,12 +999,7 @@ int ap_cache_control(request_rec *r, cache_control_t *cc, char *header = apr_pstrdup(r->pool, pragma_header); const char *token = cache_strqtok(header, CACHE_SEPARATOR, &last); while (token) { - /* handle most common quickest case... */ - if (!strcmp(token, "no-cache")) { - cc->no_cache = 1; - } - /* ...then try slowest case */ - else if (!strcasecmp(token, "no-cache")) { + if (!ap_casecmpstr(token, "no-cache")) { cc->no_cache = 1; } token = cache_strqtok(NULL, CACHE_SEPARATOR, &last); @@ -1008,21 +1008,15 @@ int ap_cache_control(request_rec *r, cache_control_t *cc, } if (cc_header) { + char *endp; + apr_off_t offt; char *header = apr_pstrdup(r->pool, cc_header); const char *token = cache_strqtok(header, CACHE_SEPARATOR, &last); while (token) { switch (token[0]) { case 'n': case 'N': { - /* handle most common quickest cases... */ - if (!strcmp(token, "no-cache")) { - cc->no_cache = 1; - } - else if (!strcmp(token, "no-store")) { - cc->no_store = 1; - } - /* ...then try slowest cases */ - else if (!strncasecmp(token, "no-cache", 8)) { + if (!ap_casecmpstrn(token, "no-cache", 8)) { if (token[8] == '=') { cc->no_cache_header = 1; } @@ -1031,73 +1025,63 @@ int ap_cache_control(request_rec *r, cache_control_t *cc, } break; } - else if (!strcasecmp(token, "no-store")) { + else if (!ap_casecmpstr(token, "no-store")) { cc->no_store = 1; } - else if (!strcasecmp(token, "no-transform")) { + else if (!ap_casecmpstr(token, "no-transform")) { cc->no_transform = 1; } break; } case 'm': case 'M': { - /* handle most common quickest cases... */ - if (!strcmp(token, "max-age=0")) { - cc->max_age = 1; - cc->max_age_value = 0; - } - else if (!strcmp(token, "must-revalidate")) { - cc->must_revalidate = 1; - } - /* ...then try slowest cases */ - else if (!strncasecmp(token, "max-age", 7)) { - if (token[7] == '=') { + if (!ap_casecmpstrn(token, "max-age", 7)) { + if (token[7] == '=' + && !apr_strtoff(&offt, token + 8, &endp, 10) + && endp > token + 8 && !*endp) { cc->max_age = 1; - cc->max_age_value = apr_atoi64(token + 8); + cc->max_age_value = offt; } - break; } - else if (!strncasecmp(token, "max-stale", 9)) { - if (token[9] == '=') { + else if (!ap_casecmpstr(token, "must-revalidate")) { + cc->must_revalidate = 1; + } + else if (!ap_casecmpstrn(token, "max-stale", 9)) { + if (token[9] == '=' + && !apr_strtoff(&offt, token + 10, &endp, 10) + && endp > token + 10 && !*endp) { cc->max_stale = 1; - cc->max_stale_value = apr_atoi64(token + 10); + cc->max_stale_value = offt; } - else if (!token[10]) { + else if (!token[9]) { cc->max_stale = 1; cc->max_stale_value = -1; } break; } - else if (!strncasecmp(token, "min-fresh", 9)) { - if (token[9] == '=') { + else if (!ap_casecmpstrn(token, "min-fresh", 9)) { + if (token[9] == '=' + && !apr_strtoff(&offt, token + 10, &endp, 10) + && endp > token + 10 && !*endp) { cc->min_fresh = 1; - cc->min_fresh_value = apr_atoi64(token + 10); + cc->min_fresh_value = offt; } break; } - else if (!strcasecmp(token, "must-revalidate")) { - cc->must_revalidate = 1; - } break; } case 'o': case 'O': { - if (!strcasecmp(token, "only-if-cached")) { + if (!ap_casecmpstr(token, "only-if-cached")) { cc->only_if_cached = 1; } break; } - case 'p': - case 'P': { - /* handle most common quickest cases... */ - if (!strcmp(token, "private")) { - cc->private = 1; - } - /* ...then try slowest cases */ - else if (!strcasecmp(token, "public")) { + case 'p': { + if (!ap_casecmpstr(token, "public")) { cc->public = 1; } - else if (!strncasecmp(token, "private", 7)) { + else if (!ap_casecmpstrn(token, "private", 7)) { if (token[7] == '=') { cc->private_header = 1; } @@ -1106,19 +1090,20 @@ int ap_cache_control(request_rec *r, cache_control_t *cc, } break; } - else if (!strcasecmp(token, "proxy-revalidate")) { + else if (!ap_casecmpstr(token, "proxy-revalidate")) { cc->proxy_revalidate = 1; } break; } case 's': case 'S': { - if (!strncasecmp(token, "s-maxage", 8)) { - if (token[8] == '=') { + if (!ap_casecmpstrn(token, "s-maxage", 8)) { + if (token[8] == '=' + && !apr_strtoff(&offt, token + 9, &endp, 10) + && endp > token + 9 && !*endp) { cc->s_maxage = 1; - cc->s_maxage_value = apr_atoi64(token + 9); + cc->s_maxage_value = offt; } - break; } break; } @@ -1148,8 +1133,7 @@ static int cache_control_remove(request_rec *r, const char *cc_header, switch (token[0]) { case 'n': case 'N': { - if (!strncmp(token, "no-cache", 8) - || !strncasecmp(token, "no-cache", 8)) { + if (!ap_casecmpstrn(token, "no-cache", 8)) { if (token[8] == '=') { const char *header = cache_strqtok(token + 9, CACHE_SEPARATOR "\"", &slast); @@ -1166,8 +1150,7 @@ static int cache_control_remove(request_rec *r, const char *cc_header, } case 'p': case 'P': { - if (!strncmp(token, "private", 7) - || !strncasecmp(token, "private", 7)) { + if (!ap_casecmpstrn(token, "private", 7)) { if (token[7] == '=') { const char *header = cache_strqtok(token + 8, CACHE_SEPARATOR "\"", &slast); diff --git a/modules/filters/mod_deflate.c b/modules/filters/mod_deflate.c index c65d029383..a8d5012203 100644 --- a/modules/filters/mod_deflate.c +++ b/modules/filters/mod_deflate.c @@ -123,8 +123,8 @@ static int check_gzip(request_rec *r, apr_table_t *hdrs1, apr_table_t *hdrs2) if (encoding && *encoding) { /* check the usual/simple case first */ - if (!strcasecmp(encoding, "gzip") - || !strcasecmp(encoding, "x-gzip")) { + if (!ap_casecmpstr(encoding, "gzip") + || !ap_casecmpstr(encoding, "x-gzip")) { found = 1; if (hdrs) { apr_table_unset(hdrs, "Content-Encoding"); @@ -142,8 +142,8 @@ static int check_gzip(request_rec *r, apr_table_t *hdrs1, apr_table_t *hdrs2) for(;;) { char *token = ap_strrchr(new_encoding, ','); if (!token) { /* gzip:identity or other:identity */ - if (!strcasecmp(new_encoding, "gzip") - || !strcasecmp(new_encoding, "x-gzip")) { + if (!ap_casecmpstr(new_encoding, "gzip") + || !ap_casecmpstr(new_encoding, "x-gzip")) { found = 1; if (hdrs) { apr_table_unset(hdrs, "Content-Encoding"); @@ -155,8 +155,8 @@ static int check_gzip(request_rec *r, apr_table_t *hdrs1, apr_table_t *hdrs2) break; /* seen all tokens */ } for (ptr=token+1; apr_isspace(*ptr); ++ptr); - if (!strcasecmp(ptr, "gzip") - || !strcasecmp(ptr, "x-gzip")) { + if (!ap_casecmpstr(ptr, "gzip") + || !ap_casecmpstr(ptr, "x-gzip")) { *token = '\0'; if (hdrs) { apr_table_setn(hdrs, "Content-Encoding", new_encoding); @@ -166,7 +166,7 @@ static int check_gzip(request_rec *r, apr_table_t *hdrs1, apr_table_t *hdrs2) } found = 1; } - else if (!ptr[0] || !strcasecmp(ptr, "identity")) { + else if (!ptr[0] || !ap_casecmpstr(ptr, "identity")) { *token = '\0'; continue; /* strip the token and find the next one */ } @@ -744,7 +744,7 @@ static apr_status_t deflate_out_filter(ap_filter_t *f, } token = ap_get_token(r->pool, &accepts, 0); - while (token && token[0] && strcasecmp(token, "gzip")) { + while (token && token[0] && ap_casecmpstr(token, "gzip")) { /* skip parameters, XXX: ;q=foo evaluation? */ while (*accepts == ';') { ++accepts; @@ -818,7 +818,7 @@ static apr_status_t deflate_out_filter(ap_filter_t *f, */ /* If the entire Content-Encoding is "identity", we can replace it. */ - if (!encoding || !strcasecmp(encoding, "identity")) { + if (!encoding || !ap_casecmpstr(encoding, "identity")) { apr_table_setn(r->headers_out, "Content-Encoding", "gzip"); } else { diff --git a/modules/filters/mod_include.c b/modules/filters/mod_include.c index 95ab4d2b22..df5231c3b0 100644 --- a/modules/filters/mod_include.c +++ b/modules/filters/mod_include.c @@ -620,16 +620,16 @@ static void add_include_vars(request_rec *r) static const char *add_include_vars_lazy(request_rec *r, const char *var, const char *timefmt) { char *val; - if (!strcasecmp(var, "DATE_LOCAL")) { + if (!ap_casecmpstr(var, "DATE_LOCAL")) { val = ap_ht_time(r->pool, r->request_time, timefmt, 0); } - else if (!strcasecmp(var, "DATE_GMT")) { + else if (!ap_casecmpstr(var, "DATE_GMT")) { val = ap_ht_time(r->pool, r->request_time, timefmt, 1); } - else if (!strcasecmp(var, "LAST_MODIFIED")) { + else if (!ap_casecmpstr(var, "LAST_MODIFIED")) { val = ap_ht_time(r->pool, r->finfo.mtime, timefmt, 0); } - else if (!strcasecmp(var, "USER_NAME")) { + else if (!ap_casecmpstr(var, "USER_NAME")) { if (apr_uid_name_get(&val, r->finfo.user, r->pool) != APR_SUCCESS) { val = ""; } @@ -714,9 +714,9 @@ static int include_expr_lookup(ap_expr_lookup_parms *parms) { switch (parms->type) { case AP_EXPR_FUNC_STRING: - if (strcasecmp(parms->name, "v") == 0 || - strcasecmp(parms->name, "reqenv") == 0 || - strcasecmp(parms->name, "env") == 0) { + if (ap_casecmpstr(parms->name, "v") == 0 || + ap_casecmpstr(parms->name, "reqenv") == 0 || + ap_casecmpstr(parms->name, "env") == 0) { *parms->func = include_expr_var_fn; *parms->data = parms->name; return OK; @@ -1947,25 +1947,25 @@ static apr_status_t handle_echo(include_ctx_t *ctx, ap_filter_t *f, token = apr_strtok(d, ", \t", &last); while (token) { - if (!strcasecmp(token, "none")) { + if (!ap_casecmpstr(token, "none")) { /* do nothing */ } - else if (!strcasecmp(token, "url")) { + else if (!ap_casecmpstr(token, "url")) { char *buf = apr_pstrdup(ctx->pool, echo_text); ap_unescape_url(buf); echo_text = buf; } - else if (!strcasecmp(token, "urlencoded")) { + else if (!ap_casecmpstr(token, "urlencoded")) { char *buf = apr_pstrdup(ctx->pool, echo_text); ap_unescape_urlencoded(buf); echo_text = buf; } - else if (!strcasecmp(token, "entity")) { + else if (!ap_casecmpstr(token, "entity")) { char *buf = apr_pstrdup(ctx->pool, echo_text); decodehtml(buf); echo_text = buf; } - else if (!strcasecmp(token, "base64")) { + else if (!ap_casecmpstr(token, "base64")) { echo_text = ap_pbase64decode(ctx->dpool, echo_text); } else { @@ -1983,19 +1983,19 @@ static apr_status_t handle_echo(include_ctx_t *ctx, ap_filter_t *f, token = apr_strtok(e, ", \t", &last); while (token) { - if (!strcasecmp(token, "none")) { + if (!ap_casecmpstr(token, "none")) { /* do nothing */ } - else if (!strcasecmp(token, "url")) { + else if (!ap_casecmpstr(token, "url")) { echo_text = ap_escape_uri(ctx->dpool, echo_text); } - else if (!strcasecmp(token, "urlencoded")) { + else if (!ap_casecmpstr(token, "urlencoded")) { echo_text = ap_escape_urlencoded(ctx->dpool, echo_text); } - else if (!strcasecmp(token, "entity")) { + else if (!ap_casecmpstr(token, "entity")) { echo_text = ap_escape_html2(ctx->dpool, echo_text, 0); } - else if (!strcasecmp(token, "base64")) { + else if (!ap_casecmpstr(token, "base64")) { char *buf; buf = ap_pbase64encode(ctx->dpool, (char *)echo_text); echo_text = buf; @@ -2585,25 +2585,25 @@ static apr_status_t handle_set(include_ctx_t *ctx, ap_filter_t *f, token = apr_strtok(d, ", \t", &last); while (token) { - if (!strcasecmp(token, "none")) { + if (!ap_casecmpstr(token, "none")) { /* do nothing */ } - else if (!strcasecmp(token, "url")) { + else if (!ap_casecmpstr(token, "url")) { char *buf = apr_pstrdup(ctx->pool, parsed_string); ap_unescape_url(buf); parsed_string = buf; } - else if (!strcasecmp(token, "urlencoded")) { + else if (!ap_casecmpstr(token, "urlencoded")) { char *buf = apr_pstrdup(ctx->pool, parsed_string); ap_unescape_urlencoded(buf); parsed_string = buf; } - else if (!strcasecmp(token, "entity")) { + else if (!ap_casecmpstr(token, "entity")) { char *buf = apr_pstrdup(ctx->pool, parsed_string); decodehtml(buf); parsed_string = buf; } - else if (!strcasecmp(token, "base64")) { + else if (!ap_casecmpstr(token, "base64")) { parsed_string = ap_pbase64decode(ctx->dpool, parsed_string); } else { @@ -2621,19 +2621,19 @@ static apr_status_t handle_set(include_ctx_t *ctx, ap_filter_t *f, token = apr_strtok(e, ", \t", &last); while (token) { - if (!strcasecmp(token, "none")) { + if (!ap_casecmpstr(token, "none")) { /* do nothing */ } - else if (!strcasecmp(token, "url")) { + else if (!ap_casecmpstr(token, "url")) { parsed_string = ap_escape_uri(ctx->dpool, parsed_string); } - else if (!strcasecmp(token, "urlencoded")) { + else if (!ap_casecmpstr(token, "urlencoded")) { parsed_string = ap_escape_urlencoded(ctx->dpool, parsed_string); } - else if (!strcasecmp(token, "entity")) { + else if (!ap_casecmpstr(token, "entity")) { parsed_string = ap_escape_html2(ctx->dpool, parsed_string, 0); } - else if (!strcasecmp(token, "base64")) { + else if (!ap_casecmpstr(token, "base64")) { char *buf; buf = ap_pbase64encode(ctx->dpool, (char *)parsed_string); parsed_string = buf; diff --git a/modules/filters/mod_proxy_html.c b/modules/filters/mod_proxy_html.c index f760829287..e949fe49aa 100644 --- a/modules/filters/mod_proxy_html.c +++ b/modules/filters/mod_proxy_html.c @@ -295,8 +295,8 @@ static void pinternalSubset(void* ctxt, const xmlChar *name, } ap_fputstrs(ctx->f->next, ctx->bb, "etag = xhtml_etag; } else { @@ -690,7 +690,7 @@ static meta *metafix(request_rec *r, const char *buf) while (!apr_isalpha(*++p)); for (q = p; apr_isalnum(*q) || (*q == '-'); ++q); header = apr_pstrndup(r->pool, p, q-p); - if (strncasecmp(header, "Content-", 8)) { + if (ap_casecmpstrn(header, "Content-", 8)) { /* find content=... string */ p = apr_strmatch(seek_content, buf+offs+pmatch[0].rm_so, pmatch[0].rm_eo - pmatch[0].rm_so); @@ -718,7 +718,7 @@ static meta *metafix(request_rec *r, const char *buf) } } } - else if (!strncasecmp(header, "Content-Type", 12)) { + else if (!ap_casecmpstrn(header, "Content-Type", 12)) { ret = apr_palloc(r->pool, sizeof(meta)); ret->start = offs+pmatch[0].rm_so; ret->end = offs+pmatch[0].rm_eo; @@ -842,8 +842,8 @@ static saxctxt *check_filter_init (ap_filter_t *f) else if (!f->r->content_type) { errmsg = "No content-type; bailing out of proxy-html filter"; } - else if (strncasecmp(f->r->content_type, "text/html", 9) && - strncasecmp(f->r->content_type, + else if (ap_casecmpstrn(f->r->content_type, "text/html", 9) && + ap_casecmpstrn(f->r->content_type, "application/xhtml+xml", 21)) { errmsg = "Non-HTML content; not inserting proxy-html filter"; } diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index a9e962315c..67d7e5a576 100644 --- a/modules/generators/mod_autoindex.c +++ b/modules/generators/mod_autoindex.c @@ -1068,7 +1068,7 @@ static void emit_head(request_rec *r, char *header_fname, int suppress_amble, emit_H1 = 1; } } - else if (!strncasecmp("text/", rr->content_type, 5)) { + else if (!ap_casecmpstrn("text/", rr->content_type, 5)) { /* * If we can open the file, prefix it with the preamble * regardless; since we'll be sending a
 block around
@@ -1163,7 +1163,7 @@ static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble)
                     suppress_post = suppress_amble;
                 }
             }
-            else if (!strncasecmp("text/", rr->content_type, 5)) {
+            else if (!ap_casecmpstrn("text/", rr->content_type, 5)) {
                 /*
                  * If we can open the file, suppress the signature.
                  */
diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c
index 7c70119c94..1e398aad6f 100644
--- a/modules/generators/mod_cgi.c
+++ b/modules/generators/mod_cgi.c
@@ -78,7 +78,7 @@ static void discard_script_output(apr_bucket_brigade *bb);
 static int is_scriptaliased(request_rec *r)
 {
     const char *t = apr_table_get(r->notes, "alias-forced-type");
-    return t && (!strcasecmp(t, "cgi-script"));
+    return t && (!ap_casecmpstr(t, "cgi-script"));
 }
 
 /* Configuration stuff */
diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c
index 4cebd04571..7b29b2e0da 100644
--- a/modules/generators/mod_cgid.c
+++ b/modules/generators/mod_cgid.c
@@ -131,7 +131,7 @@ static ap_unix_identity_t *cgid_suexec_id_doer(const request_rec *r)
 static int is_scriptaliased(request_rec *r)
 {
     const char *t = apr_table_get(r->notes, "alias-forced-type");
-    return t && (!strcasecmp(t, "cgi-script"));
+    return t && (!ap_casecmpstr(t, "cgi-script"));
 }
 
 /* Configuration stuff */
diff --git a/modules/http/byterange_filter.c b/modules/http/byterange_filter.c
index cc11140ada..7078e308a7 100644
--- a/modules/http/byterange_filter.c
+++ b/modules/http/byterange_filter.c
@@ -101,7 +101,7 @@ static int ap_set_byterange(request_rec *r, apr_off_t clength,
     }
 
     range = apr_table_get(r->headers_in, "Range");
-    if (!range || strncasecmp(range, "bytes=", 6) || r->status != HTTP_OK) {
+    if (!range || ap_casecmpstrn(range, "bytes=", 6) || r->status != HTTP_OK) {
         return 0;
     }
 
@@ -112,7 +112,7 @@ static int ap_set_byterange(request_rec *r, apr_off_t clength,
 
     /* is content already a multiple range? */
     if ((ct = apr_table_get(r->headers_out, "Content-Type"))
-        && strncasecmp(ct, "multipart/byteranges", 20) == 0) {
+        && ap_casecmpstrn(ct, "multipart/byteranges", 20) == 0) {
             return 0;
     }
 
diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c
index 4304afa3a1..c1f2a1bc4d 100644
--- a/modules/http/http_filters.c
+++ b/modules/http/http_filters.c
@@ -317,7 +317,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b,
         lenp = apr_table_get(f->r->headers_in, "Content-Length");
 
         if (tenc) {
-            if (strcasecmp(tenc, "chunked") == 0 /* fast path */
+            if (ap_casecmpstr(tenc, "chunked") == 0 /* fast path */
                     || ap_find_last_token(f->r->pool, tenc, "chunked")) {
                 ctx->state = BODY_CHUNK;
             }
@@ -764,7 +764,7 @@ static int uniq_field_values(void *d, const char *key, const char *val)
          */
         for (i = 0, strpp = (char **) values->elts; i < values->nelts;
              ++i, ++strpp) {
-            if (*strpp && strcasecmp(*strpp, start) == 0) {
+            if (*strpp && ap_casecmpstr(*strpp, start) == 0) {
                 break;
             }
         }
@@ -1543,7 +1543,7 @@ AP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy)
     r->remaining = 0;
 
     if (tenc) {
-        if (strcasecmp(tenc, "chunked")) {
+        if (ap_casecmpstr(tenc, "chunked")) {
             ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(01592)
                           "Unknown Transfer-Encoding %s", tenc);
             return HTTP_NOT_IMPLEMENTED;
diff --git a/modules/http2/h2_from_h1.c b/modules/http2/h2_from_h1.c
index 43a4f0822b..a02794f319 100644
--- a/modules/http2/h2_from_h1.c
+++ b/modules/http2/h2_from_h1.c
@@ -262,7 +262,7 @@ static int uniq_field_values(void *d, const char *key, const char *val)
          */
         for (i = 0, strpp = (char **) values->elts; i < values->nelts;
              ++i, ++strpp) {
-            if (*strpp && strcasecmp(*strpp, start) == 0) {
+            if (*strpp && ap_casecmpstr(*strpp, start) == 0) {
                 break;
             }
         }
diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c
index 50f7d36dd0..2a83e66da6 100644
--- a/modules/loggers/mod_log_config.c
+++ b/modules/loggers/mod_log_config.c
@@ -497,7 +497,7 @@ static APR_INLINE char *find_multiple_headers(apr_pool_t *pool,
     result_list = rp = NULL;
 
     do {
-        if (!strcasecmp(t_elt->key, key)) {
+        if (!ap_casecmpstr(t_elt->key, key)) {
             if (!result_list) {
                 result_list = rp = apr_palloc(pool, sizeof(*rp));
             }
@@ -541,10 +541,10 @@ static const char *log_header_out(request_rec *r, char *a)
 {
     const char *cp = NULL;
 
-    if (!strcasecmp(a, "Content-type") && r->content_type) {
+    if (!ap_casecmpstr(a, "Content-type") && r->content_type) {
         cp = ap_field_noparam(r->pool, r->content_type);
     }
-    else if (!strcasecmp(a, "Set-Cookie")) {
+    else if (!ap_casecmpstr(a, "Set-Cookie")) {
         cp = find_multiple_headers(r->pool, r->headers_out, a);
     }
     else {
@@ -808,13 +808,13 @@ static const char *log_request_duration_microseconds(request_rec *r, char *a)
 static const char *log_request_duration_scaled(request_rec *r, char *a)
 {
     apr_time_t duration = get_request_end_time(r) - r->request_time;
-    if (*a == '\0' || !strcasecmp(a, "s")) {
+    if (*a == '\0' || !ap_casecmpstr(a, "s")) {
         duration = apr_time_sec(duration);
     }
-    else if (!strcasecmp(a, "ms")) {
+    else if (!ap_casecmpstr(a, "ms")) {
         duration = apr_time_as_msec(duration);
     }
-    else if (!strcasecmp(a, "us")) {
+    else if (!ap_casecmpstr(a, "us")) {
     }
     else {
         /* bogus format */
@@ -835,13 +835,13 @@ static const char *log_server_port(request_rec *r, char *a)
 {
     apr_port_t port;
 
-    if (*a == '\0' || !strcasecmp(a, "canonical")) {
+    if (*a == '\0' || !ap_casecmpstr(a, "canonical")) {
         port = r->server->port ? r->server->port : ap_default_port(r);
     }
-    else if (!strcasecmp(a, "remote")) {
+    else if (!ap_casecmpstr(a, "remote")) {
         port = r->useragent_addr->port;
     }
-    else if (!strcasecmp(a, "local")) {
+    else if (!ap_casecmpstr(a, "local")) {
         port = r->connection->local_addr->port;
     }
     else {
@@ -861,10 +861,10 @@ static const char *log_server_name(request_rec *r, char *a)
 
 static const char *log_pid_tid(request_rec *r, char *a)
 {
-    if (*a == '\0' || !strcasecmp(a, "pid")) {
+    if (*a == '\0' || !ap_casecmpstr(a, "pid")) {
         return ap_append_pid(r->pool, "", "");
     }
-    else if (!strcasecmp(a, "tid") || !strcasecmp(a, "hextid")) {
+    else if (!ap_casecmpstr(a, "tid") || !ap_casecmpstr(a, "hextid")) {
 #if APR_HAS_THREADS
         apr_os_thread_t tid = apr_os_thread_current();
 #else
@@ -1335,14 +1335,14 @@ static const char *add_custom_log(cmd_parms *cmd, void *dummy, const char *fn,
     cls->condition_var = NULL;
     cls->condition_expr = NULL;
     if (envclause != NULL) {
-        if (strncasecmp(envclause, "env=", 4) == 0) {
+        if (ap_casecmpstrn(envclause, "env=", 4) == 0) {
             if ((envclause[4] == '\0')
                 || ((envclause[4] == '!') && (envclause[5] == '\0'))) {
                 return "missing environment variable name";
             }
             cls->condition_var = apr_pstrdup(cmd->pool, &envclause[4]);
         }
-        else if (strncasecmp(envclause, "expr=", 5) == 0) {
+        else if (ap_casecmpstrn(envclause, "expr=", 5) == 0) {
             const char *err;
             if ((envclause[5] == '\0'))
                 return "missing condition";
diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c
index b506e30b8c..99d8f6bdbc 100644
--- a/modules/mappers/mod_rewrite.c
+++ b/modules/mappers/mod_rewrite.c
@@ -525,7 +525,7 @@ static unsigned is_absolute_uri(char *uri, int *supportsqs)
     switch (*uri++) {
     case 'a':
     case 'A':
-        if (!strncasecmp(uri, "jp://", 5)) {        /* ajp://    */
+        if (!ap_casecmpstrn(uri, "jp://", 5)) {        /* ajp://    */
           *sqs = 1;
           return 6;
         }
@@ -533,7 +533,7 @@ static unsigned is_absolute_uri(char *uri, int *supportsqs)
 
     case 'b':
     case 'B':
-        if (!strncasecmp(uri, "alancer://", 10)) {   /* balancer:// */
+        if (!ap_casecmpstrn(uri, "alancer://", 10)) {   /* balancer:// */
           *sqs = 1;
           return 11;
         }
@@ -541,10 +541,10 @@ static unsigned is_absolute_uri(char *uri, int *supportsqs)
 
     case 'f':
     case 'F':
-        if (!strncasecmp(uri, "tp://", 5)) {        /* ftp://    */
+        if (!ap_casecmpstrn(uri, "tp://", 5)) {        /* ftp://    */
             return 6;
         }
-        if (!strncasecmp(uri, "cgi://", 6)) {       /* fcgi://   */
+        if (!ap_casecmpstrn(uri, "cgi://", 6)) {       /* fcgi://   */
             *sqs = 1;
             return 7;
         }
@@ -552,18 +552,18 @@ static unsigned is_absolute_uri(char *uri, int *supportsqs)
 
     case 'g':
     case 'G':
-        if (!strncasecmp(uri, "opher://", 8)) {     /* gopher:// */
+        if (!ap_casecmpstrn(uri, "opher://", 8)) {     /* gopher:// */
             return 9;
         }
         break;
 
     case 'h':
     case 'H':
-        if (!strncasecmp(uri, "ttp://", 6)) {       /* http://   */
+        if (!ap_casecmpstrn(uri, "ttp://", 6)) {       /* http://   */
             *sqs = 1;
             return 7;
         }
-        else if (!strncasecmp(uri, "ttps://", 7)) { /* https://  */
+        else if (!ap_casecmpstrn(uri, "ttps://", 7)) { /* https://  */
             *sqs = 1;
             return 8;
         }
@@ -571,14 +571,14 @@ static unsigned is_absolute_uri(char *uri, int *supportsqs)
 
     case 'l':
     case 'L':
-        if (!strncasecmp(uri, "dap://", 6)) {       /* ldap://   */
+        if (!ap_casecmpstrn(uri, "dap://", 6)) {       /* ldap://   */
             return 7;
         }
         break;
 
     case 'm':
     case 'M':
-        if (!strncasecmp(uri, "ailto:", 6)) {       /* mailto:   */
+        if (!ap_casecmpstrn(uri, "ailto:", 6)) {       /* mailto:   */
             *sqs = 1;
             return 7;
         }
@@ -586,17 +586,17 @@ static unsigned is_absolute_uri(char *uri, int *supportsqs)
 
     case 'n':
     case 'N':
-        if (!strncasecmp(uri, "ews:", 4)) {         /* news:     */
+        if (!ap_casecmpstrn(uri, "ews:", 4)) {         /* news:     */
             return 5;
         }
-        else if (!strncasecmp(uri, "ntp://", 6)) {  /* nntp://   */
+        else if (!ap_casecmpstrn(uri, "ntp://", 6)) {  /* nntp://   */
             return 7;
         }
         break;
 
     case 's':
     case 'S':
-        if (!strncasecmp(uri, "cgi://", 6)) {       /* scgi://   */
+        if (!ap_casecmpstrn(uri, "cgi://", 6)) {       /* scgi://   */
             *sqs = 1;
             return 7;
         }
@@ -604,11 +604,11 @@ static unsigned is_absolute_uri(char *uri, int *supportsqs)
 
     case 'w':
     case 'W':
-        if (!strncasecmp(uri, "s://", 4)) {        /* ws://     */
+        if (!ap_casecmpstrn(uri, "s://", 4)) {        /* ws://     */
             *sqs = 1;
             return 5;
         }
-        else if (!strncasecmp(uri, "ss://", 5)) {  /* wss://    */
+        else if (!ap_casecmpstrn(uri, "ss://", 5)) {  /* wss://    */
             *sqs = 1;
             return 6;
         }
@@ -716,7 +716,7 @@ static char *escape_absolute_uri(apr_pool_t *p, char *uri, unsigned scheme)
          *               [dn ["?" [attributes] ["?" [scope]
          *               ["?" [filter] ["?" extensions]]]]]]
          */
-        if (!strncasecmp(uri, "ldap", 4)) {
+        if (!ap_casecmpstrn(uri, "ldap", 4)) {
             char *token[5];
             int c = 0;
 
@@ -1576,7 +1576,7 @@ static char *lookup_map_program(request_rec *r, apr_file_t *fpin,
     }
 
     /* catch the "failed" case */
-    if (i == 4 && !strcasecmp(buf, "NULL")) {
+    if (i == 4 && !ap_casecmpstr(buf, "NULL")) {
         return NULL;
     }
 
@@ -1829,7 +1829,7 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)
 
     /* fast tests for variable length variables (sic) first */
     if (var[3] == ':') {
-        if (var[4] && !strncasecmp(var, "ENV", 3)) {
+        if (var[4] && !ap_casecmpstrn(var, "ENV", 3)) {
             var += 4;
             result = apr_table_get(r->notes, var);
 
@@ -1840,7 +1840,7 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)
                 result = getenv(var);
             }
         }
-        else if (var[4] && !strncasecmp(var, "SSL", 3) && rewrite_ssl_lookup) {
+        else if (var[4] && !ap_casecmpstrn(var, "SSL", 3) && rewrite_ssl_lookup) {
             result = rewrite_ssl_lookup(r->pool, r->server, r->connection, r,
                                         var + 4);
         }
@@ -1850,10 +1850,10 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)
             request_rec *rr;
             const char *path;
 
-            if (!strncasecmp(var, "HTTP", 4)) {
+            if (!ap_casecmpstrn(var, "HTTP", 4)) {
                 result = lookup_header(var+5, ctx);
             }
-            else if (!strncasecmp(var, "LA-U", 4)) {
+            else if (!ap_casecmpstrn(var, "LA-U", 4)) {
                 if (ctx->uri && subreq_ok(r)) {
                     path = ctx->perdir ? la_u(ctx) : ctx->uri;
                     rr = ap_sub_req_lookup_uri(path, r, NULL);
@@ -1868,7 +1868,7 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)
                     return (char *)result;
                 }
             }
-            else if (!strncasecmp(var, "LA-F", 4)) {
+            else if (!ap_casecmpstrn(var, "LA-F", 4)) {
                 if (ctx->uri && subreq_ok(r)) {
                     path = ctx->uri;
                     if (ctx->perdir && *path == '/') {
@@ -2575,14 +2575,14 @@ static void add_cookie(request_rec *r, char *s)
                                  : NULL,
                                  expires ? (exp_time ? exp_time : "")
                                  : NULL,
-                                 (secure && (!strcasecmp(secure, "true")
+                                 (secure && (!ap_casecmpstr(secure, "true")
                                              || !strcmp(secure, "1")
-                                             || !strcasecmp(secure,
+                                             || !ap_casecmpstr(secure,
                                                             "secure"))) ?
                                   "; secure" : NULL,
-                                 (httponly && (!strcasecmp(httponly, "true")
+                                 (httponly && (!ap_casecmpstr(httponly, "true")
                                                || !strcmp(httponly, "1")
-                                               || !strcasecmp(httponly,
+                                               || !ap_casecmpstr(httponly,
                                                               "HttpOnly"))) ?
                                   "; HttpOnly" : NULL,
                                  NULL);
diff --git a/modules/metadata/mod_cern_meta.c b/modules/metadata/mod_cern_meta.c
index 09a41e1cc6..8cdeb3e7b9 100644
--- a/modules/metadata/mod_cern_meta.c
+++ b/modules/metadata/mod_cern_meta.c
@@ -240,7 +240,7 @@ static int scan_meta_file(request_rec *r, apr_file_t *f)
         while (apr_isspace(*l))
             ++l;
 
-        if (!strcasecmp(w, "Content-type")) {
+        if (!ap_casecmpstr(w, "Content-type")) {
             char *tmp;
             /* Nuke trailing whitespace */
 
@@ -252,7 +252,7 @@ static int scan_meta_file(request_rec *r, apr_file_t *f)
             ap_content_type_tolower(tmp);
             ap_set_content_type(r, tmp);
         }
-        else if (!strcasecmp(w, "Status")) {
+        else if (!ap_casecmpstr(w, "Status")) {
             sscanf(l, "%d", &r->status);
             r->status_line = apr_pstrdup(r->pool, l);
         }
diff --git a/modules/metadata/mod_headers.c b/modules/metadata/mod_headers.c
index 210b2bbb57..a21f71efd0 100644
--- a/modules/metadata/mod_headers.c
+++ b/modules/metadata/mod_headers.c
@@ -789,14 +789,14 @@ static int do_headers_fixup(request_rec *r, apr_table_t *headers,
             }
             break;
         case hdr_set:
-            if (!strcasecmp(hdr->header, "Content-Type")) {
+            if (!ap_casecmpstr(hdr->header, "Content-Type")) {
                  ap_set_content_type(r, process_tags(hdr, r));
             }
             apr_table_setn(headers, hdr->header, process_tags(hdr, r));
             break;
         case hdr_setifempty:
             if (NULL == apr_table_get(headers, hdr->header)) {
-                if (!strcasecmp(hdr->header, "Content-Type")) {
+                if (!ap_casecmpstr(hdr->header, "Content-Type")) {
                     ap_set_content_type(r, process_tags(hdr, r));
                 }
                 apr_table_setn(headers, hdr->header, process_tags(hdr, r));
@@ -813,7 +813,7 @@ static int do_headers_fixup(request_rec *r, apr_table_t *headers,
             break;
         case hdr_edit:
         case hdr_edit_r:
-            if (!strcasecmp(hdr->header, "Content-Type") && r->content_type) {
+            if (!ap_casecmpstr(hdr->header, "Content-Type") && r->content_type) {
                 const char *repl = process_regexp(hdr, r->content_type, r);
                 if (repl == NULL)
                     return 0;
diff --git a/modules/proxy/ajp_header.c b/modules/proxy/ajp_header.c
index 0ec94ad780..dff06567fe 100644
--- a/modules/proxy/ajp_header.c
+++ b/modules/proxy/ajp_header.c
@@ -633,15 +633,15 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
         }
 
         /* Set-Cookie need additional processing */
-        if (!strcasecmp(stringname, "Set-Cookie")) {
+        if (!ap_casecmpstr(stringname, "Set-Cookie")) {
             value = ap_proxy_cookie_reverse_map(r, dconf, value);
         }
         /* Location, Content-Location, URI and Destination need additional
          * processing */
-        else if (!strcasecmp(stringname, "Location")
-                 || !strcasecmp(stringname, "Content-Location")
-                 || !strcasecmp(stringname, "URI")
-                 || !strcasecmp(stringname, "Destination"))
+        else if (!ap_casecmpstr(stringname, "Location")
+                 || !ap_casecmpstr(stringname, "Content-Location")
+                 || !ap_casecmpstr(stringname, "URI")
+                 || !ap_casecmpstr(stringname, "Destination"))
         {
           value = ap_proxy_location_reverse_map(r, dconf, value);
         }
@@ -654,7 +654,7 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
         apr_table_add(r->headers_out, stringname, value);
 
         /* Content-type needs an additional handling */
-        if (strcasecmp(stringname, "Content-Type") == 0) {
+        if (ap_casecmpstr(stringname, "Content-Type") == 0) {
              /* add corresponding filter */
             ap_set_content_type(r, apr_pstrdup(r->pool, value));
             ap_log_rerror(APLOG_MARK, APLOG_TRACE5, 0, r,
diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c
index d9381332b5..a949afb3cc 100644
--- a/modules/proxy/mod_proxy.c
+++ b/modules/proxy/mod_proxy.c
@@ -1105,9 +1105,9 @@ static int proxy_handler(request_rec *r)
                 if (strcmp(ents[i].scheme, "*") == 0 ||
                     (ents[i].use_regex &&
                      ap_regexec(ents[i].regexp, url, 0, NULL, 0) == 0) ||
-                    (p2 == NULL && strcasecmp(scheme, ents[i].scheme) == 0) ||
+                    (p2 == NULL && ap_casecmpstr(scheme, ents[i].scheme) == 0) ||
                     (p2 != NULL &&
-                    strncasecmp(url, ents[i].scheme,
+                    ap_casecmpstrn(url, ents[i].scheme,
                                 strlen(ents[i].scheme)) == 0)) {
 
                     /* handle the scheme */
@@ -1593,7 +1593,7 @@ PROXY_DECLARE(const char *) ap_proxy_de_socketfy(apr_pool_t *p, const char *url)
      * We could be passed a URL during the config stage that contains
      * the UDS path... ignore it
      */
-    if (!strncasecmp(url, "unix:", 5) &&
+    if (!ap_casecmpstrn(url, "unix:", 5) &&
         ((ptr = ap_strchr_c(url, '|')) != NULL)) {
         /* move past the 'unix:...|' UDS path info */
         const char *ret, *c;
diff --git a/modules/proxy/mod_proxy_ajp.c b/modules/proxy/mod_proxy_ajp.c
index ece475ddf6..0a6ea595a1 100644
--- a/modules/proxy/mod_proxy_ajp.c
+++ b/modules/proxy/mod_proxy_ajp.c
@@ -35,7 +35,7 @@ static int proxy_ajp_canon(request_rec *r, char *url)
     apr_port_t port, def_port;
 
     /* ap_port_of_scheme() */
-    if (strncasecmp(url, "ajp:", 4) == 0) {
+    if (ap_casecmpstrn(url, "ajp:", 4) == 0) {
         url += 4;
     }
     else {
@@ -243,7 +243,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
     /* read the first bloc of data */
     input_brigade = apr_brigade_create(p, r->connection->bucket_alloc);
     tenc = apr_table_get(r->headers_in, "Transfer-Encoding");
-    if (tenc && (strcasecmp(tenc, "chunked") == 0)) {
+    if (tenc && (ap_casecmpstr(tenc, "chunked") == 0)) {
         /* The AJP protocol does not want body data yet */
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00870) "request is chunked");
     } else {
@@ -746,7 +746,7 @@ static int proxy_ajp_handler(request_rec *r, proxy_worker *worker,
     apr_pool_t *p = r->pool;
     apr_uri_t *uri;
 
-    if (strncasecmp(url, "ajp:", 4) != 0) {
+    if (ap_casecmpstrn(url, "ajp:", 4) != 0) {
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00894) "declining URL %s", url);
         return DECLINED;
     }
diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c
index 67295be3ab..d9e69ca288 100644
--- a/modules/proxy/mod_proxy_balancer.c
+++ b/modules/proxy/mod_proxy_balancer.c
@@ -63,7 +63,7 @@ static int proxy_balancer_canon(request_rec *r, char *url)
     apr_port_t port = 0;
 
     /* TODO: offset of BALANCER_PREFIX ?? */
-    if (strncasecmp(url, "balancer:", 9) == 0) {
+    if (ap_casecmpstrn(url, "balancer:", 9) == 0) {
         url += 9;
     }
     else {
@@ -1380,7 +1380,7 @@ static int balancer_handler(request_rec *r)
                 ap_rprintf(r, "          %d\n",
                            worker->s->lbset);
                 /* End proxy_worker_stat */
-                if (!strcasecmp(worker->s->scheme, "ajp")) {
+                if (!ap_casecmpstr(worker->s->scheme, "ajp")) {
                     ap_rputs("          ", r);
                     switch (worker->s->flush_packets) {
                         case flush_off:
diff --git a/modules/proxy/mod_proxy_fcgi.c b/modules/proxy/mod_proxy_fcgi.c
index ba813ed500..48dc81f13e 100644
--- a/modules/proxy/mod_proxy_fcgi.c
+++ b/modules/proxy/mod_proxy_fcgi.c
@@ -39,7 +39,7 @@ static int proxy_fcgi_canon(request_rec *r, char *url)
     fcgi_req_config_t *rconf = NULL;
     const char *pathinfo_type = NULL;
 
-    if (strncasecmp(url, "fcgi:", 5) == 0) {
+    if (ap_casecmpstrn(url, "fcgi:", 5) == 0) {
         url += 5;
     }
     else {
@@ -878,7 +878,7 @@ static int proxy_fcgi_handler(request_rec *r, proxy_worker *worker,
                   "url: %s proxyname: %s proxyport: %d",
                  url, proxyname, proxyport);
 
-    if (strncasecmp(url, "fcgi:", 5) != 0) {
+    if (ap_casecmpstrn(url, "fcgi:", 5) != 0) {
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01077) "declining URL %s", url);
         return DECLINED;
     }
diff --git a/modules/proxy/mod_proxy_fdpass.c b/modules/proxy/mod_proxy_fdpass.c
index 63cf469664..6f550c0e37 100644
--- a/modules/proxy/mod_proxy_fdpass.c
+++ b/modules/proxy/mod_proxy_fdpass.c
@@ -32,7 +32,7 @@ static int proxy_fdpass_canon(request_rec *r, char *url)
 {
     const char *path;
 
-    if (strncasecmp(url, "fd://", 5) == 0) {
+    if (ap_casecmpstrn(url, "fd://", 5) == 0) {
         url += 5;
     }
     else {
@@ -132,7 +132,7 @@ static int proxy_fdpass_handler(request_rec *r, proxy_worker *worker,
     apr_socket_t *sock;
     apr_socket_t *clientsock;
 
-    if (strncasecmp(url, "fd://", 5) == 0) {
+    if (ap_casecmpstrn(url, "fd://", 5) == 0) {
         url += 5;
     }
     else {
diff --git a/modules/proxy/mod_proxy_ftp.c b/modules/proxy/mod_proxy_ftp.c
index 934cb2b8e6..7e0341a52a 100644
--- a/modules/proxy/mod_proxy_ftp.c
+++ b/modules/proxy/mod_proxy_ftp.c
@@ -294,7 +294,7 @@ static int proxy_ftp_canon(request_rec *r, char *url)
     apr_port_t port, def_port;
 
     /* */
-    if (strncasecmp(url, "ftp:", 4) == 0) {
+    if (ap_casecmpstrn(url, "ftp:", 4) == 0) {
         url += 4;
     }
     else {
@@ -494,7 +494,7 @@ static apr_status_t proxy_send_dir_filter(ap_filter_t *f,
         path = apr_uri_unparse(p, &f->r->parsed_uri, APR_URI_UNP_OMITSITEPART | APR_URI_UNP_OMITQUERY);
 
         /* If path began with /%2f, change the basedir */
-        if (strncasecmp(path, "/%2f", 4) == 0) {
+        if (ap_casecmpstrn(path, "/%2f", 4) == 0) {
             basedir = "/%2f";
         }
 
@@ -1011,7 +1011,7 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
                       proxyhost);
         return DECLINED;        /* proxy connections are via HTTP */
     }
-    if (strncasecmp(url, "ftp:", 4)) {
+    if (ap_casecmpstrn(url, "ftp:", 4)) {
         ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r,
                       "declining URL %s - not ftp:", url);
         return DECLINED;        /* only interested in FTP */
@@ -1082,7 +1082,7 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
      * still smaller that the URL is logged regularly.
      */
     if ((password = apr_table_get(r->headers_in, "Authorization")) != NULL
-        && strcasecmp(ap_getword(r->pool, &password, ' '), "Basic") == 0
+        && ap_casecmpstr(ap_getword(r->pool, &password, ' '), "Basic") == 0
         && (password = ap_pbase64decode(r->pool, password))[0] != ':') {
         /* Check the decoded string for special characters. */
         if (!ftp_check_string(password)) {
@@ -1328,7 +1328,7 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
     /* Special handling for leading "%2f": this enforces a "cwd /"
      * out of the $HOME directory which was the starting point after login
      */
-    if (strncasecmp(path, "%2f", 3) == 0) {
+    if (ap_casecmpstrn(path, "%2f", 3) == 0) {
         path += 3;
         while (*path == '/') /* skip leading '/' (after root %2f) */
             ++path;
diff --git a/modules/proxy/mod_proxy_http.c b/modules/proxy/mod_proxy_http.c
index 8c048ecbab..c367604b49 100644
--- a/modules/proxy/mod_proxy_http.c
+++ b/modules/proxy/mod_proxy_http.c
@@ -43,11 +43,11 @@ static int proxy_http_canon(request_rec *r, char *url)
     apr_port_t port, def_port;
 
     /* ap_port_of_scheme() */
-    if (strncasecmp(url, "http:", 5) == 0) {
+    if (ap_casecmpstrn(url, "http:", 5) == 0) {
         url += 5;
         scheme = "http";
     }
-    else if (strncasecmp(url, "https:", 6) == 0) {
+    else if (ap_casecmpstrn(url, "https:", 6) == 0) {
         url += 6;
         scheme = "https";
     }
@@ -792,7 +792,7 @@ static int ap_proxy_http_prefetch(apr_pool_t *p, request_rec *r,
      * encoding has been done by the extensions' handler, and
      * do not modify add_te_chunked's logic
      */
-    if (*old_te_val && strcasecmp(*old_te_val, "chunked") != 0) {
+    if (*old_te_val && ap_casecmpstr(*old_te_val, "chunked") != 0) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01093)
                       "%s Transfer-Encoding is not supported", *old_te_val);
         return HTTP_INTERNAL_SERVER_ERROR;
@@ -1113,14 +1113,14 @@ static void process_proxy_header(request_rec *r, proxy_dir_conf *c,
     };
     int i;
     for (i = 0; date_hdrs[i]; ++i) {
-        if (!strcasecmp(date_hdrs[i], key)) {
+        if (!ap_casecmpstr(date_hdrs[i], key)) {
             apr_table_add(r->headers_out, key,
                           date_canon(r->pool, value));
             return;
         }
     }
     for (i = 0; transform_hdrs[i].name; ++i) {
-        if (!strcasecmp(transform_hdrs[i].name, key)) {
+        if (!ap_casecmpstr(transform_hdrs[i].name, key)) {
             apr_table_add(r->headers_out, key,
                           (*transform_hdrs[i].func)(r, c, value));
             return;
diff --git a/modules/proxy/mod_proxy_scgi.c b/modules/proxy/mod_proxy_scgi.c
index 2cbe8483f3..224d1ef123 100644
--- a/modules/proxy/mod_proxy_scgi.c
+++ b/modules/proxy/mod_proxy_scgi.c
@@ -180,7 +180,7 @@ static int scgi_canon(request_rec *r, char *url)
     const char *err, *path;
     apr_port_t port, def_port;
 
-    if (strncasecmp(url, SCHEME "://", sizeof(SCHEME) + 2)) {
+    if (ap_casecmpstrn(url, SCHEME "://", sizeof(SCHEME) + 2)) {
         return DECLINED;
     }
     url += sizeof(SCHEME); /* Keep slashes */
@@ -434,7 +434,7 @@ static int pass_response(request_rec *r, proxy_conn_rec *conn)
         if (location && *location == '/') {
             scgi_request_config *req_conf = apr_palloc(r->pool,
                                                        sizeof(*req_conf));
-            if (strcasecmp(location_header, "Location")) {
+            if (ap_casecmpstr(location_header, "Location")) {
                 if (err) {
                     apr_table_unset(r->err_headers_out, location_header);
                 }
@@ -533,7 +533,7 @@ static int scgi_handler(request_rec *r, proxy_worker *worker,
     apr_uri_t *uri = apr_palloc(r->pool, sizeof(*uri));
     char dummy;
 
-    if (strncasecmp(url, SCHEME "://", sizeof(SCHEME) + 2)) {
+    if (ap_casecmpstrn(url, SCHEME "://", sizeof(SCHEME) + 2)) {
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00865)
                       "declining URL %s", url);
         return DECLINED;
diff --git a/modules/proxy/mod_proxy_wstunnel.c b/modules/proxy/mod_proxy_wstunnel.c
index 1602cbbb71..56a01e68d9 100644
--- a/modules/proxy/mod_proxy_wstunnel.c
+++ b/modules/proxy/mod_proxy_wstunnel.c
@@ -211,12 +211,12 @@ static int proxy_wstunnel_canon(request_rec *r, char *url)
     apr_port_t port, def_port;
 
     /* ap_port_of_scheme() */
-    if (strncasecmp(url, "ws:", 3) == 0) {
+    if (ap_casecmpstrn(url, "ws:", 3) == 0) {
         url += 3;
         scheme = "ws:";
         def_port = apr_uri_port_of_scheme("http");
     }
-    else if (strncasecmp(url, "wss:", 4) == 0) {
+    else if (ap_casecmpstrn(url, "wss:", 4) == 0) {
         url += 4;
         scheme = "wss:";
         def_port = apr_uri_port_of_scheme("https");
@@ -474,11 +474,11 @@ static int proxy_wstunnel_handler(request_rec *r, proxy_worker *worker,
     apr_uri_t *uri;
     int is_ssl = 0;
 
-    if (strncasecmp(url, "wss:", 4) == 0) {
+    if (ap_casecmpstrn(url, "wss:", 4) == 0) {
         scheme = "WSS";
         is_ssl = 1;
     }
-    else if (strncasecmp(url, "ws:", 3) == 0) {
+    else if (ap_casecmpstrn(url, "ws:", 3) == 0) {
         scheme = "WS";
     }
     else {
@@ -487,7 +487,7 @@ static int proxy_wstunnel_handler(request_rec *r, proxy_worker *worker,
     }
 
     upgrade = apr_table_get(r->headers_in, "Upgrade");
-    if (!upgrade || strcasecmp(upgrade, "WebSocket") != 0) {
+    if (!upgrade || ap_casecmpstr(upgrade, "WebSocket") != 0) {
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02900)
                       "declining URL %s  (not WebSocket)", url);
         return DECLINED;
diff --git a/modules/proxy/mod_serf.c b/modules/proxy/mod_serf.c
index 520885b75c..47cde1584b 100644
--- a/modules/proxy/mod_serf.c
+++ b/modules/proxy/mod_serf.c
@@ -151,40 +151,40 @@ static int copy_headers_in(void *vbaton, const char *key, const char *value)
     switch (key[0]) {
     case 'a':
     case 'A':
-        if (strcasecmp("Accept-Encoding", key) == 0) {
+        if (ap_casecmpstr("Accept-Encoding", key) == 0) {
             return 0;
         }
         break;
     case 'c':
     case 'C':
-        if (strcasecmp("Connection", key) == 0) {
+        if (ap_casecmpstr("Connection", key) == 0) {
             return 0;
         }
         break;
     case 'h':
     case 'H':
-        if (strcasecmp("Host", key) == 0) {
+        if (ap_casecmpstr("Host", key) == 0) {
             return 0;
         }
         break;
     case 'k':
     case 'K':
-        if (strcasecmp("Keep-Alive", key) == 0) {
+        if (ap_casecmpstr("Keep-Alive", key) == 0) {
             return 0;
         }
         break;
     case 't':
     case 'T':
-        if (strcasecmp("TE", key) == 0) {
+        if (ap_casecmpstr("TE", key) == 0) {
             return 0;
         }
-        if (strcasecmp("Trailer", key) == 0) {
+        if (ap_casecmpstr("Trailer", key) == 0) {
             return 0;
         }
         break;
     case 'u':
     case 'U':
-        if (strcasecmp("Upgrade", key) == 0) {
+        if (ap_casecmpstr("Upgrade", key) == 0) {
             return 0;
         }
         break;
@@ -205,27 +205,27 @@ static int copy_headers_out(void *vbaton, const char *key, const char *value)
     switch (key[0]) {
     case 'c':
     case 'C':
-        if (strcasecmp("Content-Type", key) == 0) {
+        if (ap_casecmpstr("Content-Type", key) == 0) {
             ap_set_content_type(ctx->r, value);
             done = 1;
             break;
         }
-        else if (strcasecmp("Connection", key) == 0) {
+        else if (ap_casecmpstr("Connection", key) == 0) {
             done = 1;
             break;
         }
-        else if (strcasecmp("Content-Encoding", key) == 0) {
+        else if (ap_casecmpstr("Content-Encoding", key) == 0) {
             done = 1;
             break;
         }
-        else if (strcasecmp("Content-Length", key) == 0) {
+        else if (ap_casecmpstr("Content-Length", key) == 0) {
             done = 1;
             break;
         }
         break;
     case 't':
     case 'T':
-        if (strcasecmp("Transfer-Encoding", key) == 0) {
+        if (ap_casecmpstr("Transfer-Encoding", key) == 0) {
             done = 1;
             break;
         }
@@ -512,7 +512,7 @@ static int drive_serf(request_rec *r, serf_config_t *conf)
     baton->done_headers = 0;
     baton->keep_reading = 1;
 
-    if (strcasecmp(conf->url.scheme, "https") == 0) {
+    if (ap_casecmpstr(conf->url.scheme, "https") == 0) {
         baton->want_ssl = 1;
     }
     else {
diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c
index 4f5db685e8..5dd0ce0d25 100644
--- a/modules/proxy/proxy_util.c
+++ b/modules/proxy/proxy_util.c
@@ -1074,7 +1074,7 @@ PROXY_DECLARE(int) ap_proxy_valid_balancer_name(char *name, int i)
 {
     if (!i)
         i = sizeof(BALANCER_PREFIX)-1;
-    return (!strncasecmp(name, BALANCER_PREFIX, i));
+    return (!ap_casecmpstrn(name, BALANCER_PREFIX, i));
 }
 
 
@@ -1677,7 +1677,7 @@ PROXY_DECLARE(char *) ap_proxy_define_worker(apr_pool_t *p,
     if (ptr) {
         *ptr = '\0';
         rv = apr_uri_parse(p, url, &urisock);
-        if (rv == APR_SUCCESS && !strcasecmp(urisock.scheme, "unix")) {
+        if (rv == APR_SUCCESS && !ap_casecmpstr(urisock.scheme, "unix")) {
             sockpath = ap_runtime_dir_relative(p, urisock.path);;
             url = ptr+1;    /* so we get the scheme for the uds */
         }
@@ -3330,7 +3330,7 @@ static int ap_proxy_clear_connection(request_rec *r, apr_table_t *headers)
             ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02807)
                           "Removing header '%s' listed in Connection header",
                           name);
-            if (!strcasecmp(name, "close")) {
+            if (!ap_casecmpstr(name, "close")) {
                 closed = 1;
             }
             apr_table_unset(headers, name);
@@ -3494,7 +3494,7 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_pool_t *p,
 
         /* Add the Expect header if not already there. */
         if (((val = apr_table_get(r->headers_in, "Expect")) == NULL)
-                || (strcasecmp(val, "100-Continue") != 0 /* fast path */
+                || (ap_casecmpstr(val, "100-Continue") != 0 /* fast path */
                     && !ap_find_token(r->pool, val, "100-Continue"))) {
             apr_table_mergen(r->headers_in, "Expect", "100-Continue");
         }
@@ -3559,15 +3559,15 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_pool_t *p,
             || headers_in[counter].val == NULL
 
             /* Already sent */
-            || !strcasecmp(headers_in[counter].key, "Host")
+            || !ap_casecmpstr(headers_in[counter].key, "Host")
 
             /* Clear out hop-by-hop request headers not to send
              * RFC2616 13.5.1 says we should strip these headers
              */
-            || !strcasecmp(headers_in[counter].key, "Keep-Alive")
-            || !strcasecmp(headers_in[counter].key, "TE")
-            || !strcasecmp(headers_in[counter].key, "Trailer")
-            || !strcasecmp(headers_in[counter].key, "Upgrade")
+            || !ap_casecmpstr(headers_in[counter].key, "Keep-Alive")
+            || !ap_casecmpstr(headers_in[counter].key, "TE")
+            || !ap_casecmpstr(headers_in[counter].key, "Trailer")
+            || !ap_casecmpstr(headers_in[counter].key, "Upgrade")
 
             ) {
             continue;
@@ -3577,7 +3577,7 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_pool_t *p,
          * If we have used it then MAYBE: RFC2616 says we MAY propagate it.
          * So let's make it configurable by env.
          */
-        if (!strcasecmp(headers_in[counter].key,"Proxy-Authorization")) {
+        if (!ap_casecmpstr(headers_in[counter].key,"Proxy-Authorization")) {
             if (r->user != NULL) { /* we've authenticated */
                 if (!apr_table_get(r->subprocess_env, "Proxy-Chain-Auth")) {
                     continue;
@@ -3587,22 +3587,22 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_pool_t *p,
 
         /* Skip Transfer-Encoding and Content-Length for now.
          */
-        if (!strcasecmp(headers_in[counter].key, "Transfer-Encoding")) {
+        if (!ap_casecmpstr(headers_in[counter].key, "Transfer-Encoding")) {
             *old_te_val = headers_in[counter].val;
             continue;
         }
-        if (!strcasecmp(headers_in[counter].key, "Content-Length")) {
+        if (!ap_casecmpstr(headers_in[counter].key, "Content-Length")) {
             *old_cl_val = headers_in[counter].val;
             continue;
         }
 
         /* for sub-requests, ignore freshness/expiry headers */
         if (r->main) {
-            if (   !strcasecmp(headers_in[counter].key, "If-Match")
-                || !strcasecmp(headers_in[counter].key, "If-Modified-Since")
-                || !strcasecmp(headers_in[counter].key, "If-Range")
-                || !strcasecmp(headers_in[counter].key, "If-Unmodified-Since")
-                || !strcasecmp(headers_in[counter].key, "If-None-Match")) {
+            if (   !ap_casecmpstr(headers_in[counter].key, "If-Match")
+                || !ap_casecmpstr(headers_in[counter].key, "If-Modified-Since")
+                || !ap_casecmpstr(headers_in[counter].key, "If-Range")
+                || !ap_casecmpstr(headers_in[counter].key, "If-Unmodified-Since")
+                || !ap_casecmpstr(headers_in[counter].key, "If-None-Match")) {
                 continue;
             }
         }
@@ -3687,7 +3687,7 @@ PROXY_DECLARE(apr_port_t) ap_proxy_port_of_scheme(const char *scheme)
         } else {
             proxy_schemes_t *pscheme;
             for (pscheme = pschemes; pscheme->name != NULL; ++pscheme) {
-                if (strcasecmp(scheme, pscheme->name) == 0) {
+                if (ap_casecmpstr(scheme, pscheme->name) == 0) {
                     return pscheme->default_port;
                 }
             }
diff --git a/modules/slotmem/mod_slotmem_shm.c b/modules/slotmem/mod_slotmem_shm.c
index 4f0eeeaeb9..27a0732f5e 100644
--- a/modules/slotmem/mod_slotmem_shm.c
+++ b/modules/slotmem/mod_slotmem_shm.c
@@ -111,7 +111,7 @@ static int slotmem_filenames(apr_pool_t *pool,
 {
     const char *fname = NULL, *pname = NULL;
 
-    if (slotname && *slotname && strcasecmp(slotname, "none") != 0) {
+    if (slotname && *slotname && ap_casecmpstr(slotname, "none") != 0) {
         if (slotname[0] != '/') {
 #if !SLOTMEM_UNLINK_SEMANTIC
             /* Each generation needs its own file name. */
diff --git a/modules/test/mod_policy.c b/modules/test/mod_policy.c
index 74dcd8a2e9..18c0e74a6d 100644
--- a/modules/test/mod_policy.c
+++ b/modules/test/mod_policy.c
@@ -544,12 +544,7 @@ static apr_status_t policy_nocache_out_filter(ap_filter_t *f,
             char *header = apr_pstrdup(r->pool, pragma_header);
             const char *token = apr_strtok(header, ", ", &last);
             while (token) {
-                /* handle most common quickest case... */
-                if (!strcmp(token, "no-cache")) {
-                    fail = 1;
-                }
-                /* ...then try slowest case */
-                else if (!strcasecmp(token, "no-cache")) {
+                if (!ap_casecmpstr(token, "no-cache")) {
                     fail = 1;
                 }
                 token = apr_strtok(NULL, ", ", &last);
@@ -563,15 +558,7 @@ static apr_status_t policy_nocache_out_filter(ap_filter_t *f,
                 switch (token[0]) {
                 case 'n':
                 case 'N': {
-                    /* handle most common quickest cases... */
-                    if (!strcmp(token, "no-cache")) {
-                        fail = 1;
-                    }
-                    else if (!strcmp(token, "no-store")) {
-                        fail = 1;
-                    }
-                    /* ...then try slowest cases */
-                    else if (!strncasecmp(token, "no-cache", 8)) {
+                    if (!ap_casecmpstrn(token, "no-cache", 8)) {
                         if (token[8] == '=') {
                         }
                         else if (!token[8]) {
@@ -579,19 +566,14 @@ static apr_status_t policy_nocache_out_filter(ap_filter_t *f,
                         }
                         break;
                     }
-                    else if (!strcasecmp(token, "no-store")) {
+                    else if (!ap_casecmpstr(token, "no-store")) {
                         fail = 1;
                     }
                     break;
                 }
                 case 'p':
                 case 'P': {
-                    /* handle most common quickest cases... */
-                    if (!strcmp(token, "private")) {
-                        fail = 1;
-                    }
-                    /* ...then try slowest cases */
-                    else if (!strncasecmp(token, "private", 7)) {
+                    if (!ap_casecmpstrn(token, "private", 7)) {
                         if (token[7] == '=') {
                         }
                         else if (!token[7]) {
@@ -662,13 +644,7 @@ static apr_status_t policy_maxage_out_filter(ap_filter_t *f,
                 switch (token[0]) {
                 case 'm':
                 case 'M': {
-                    /* handle most common quickest cases... */
-                    if (!strncmp(token, "max-age", 7)) {
-                        max_age = 1;
-                        max_age_value = apr_atoi64(token + 8);
-                    }
-                    /* ...then try slowest cases */
-                    else if (!strncasecmp(token, "max-age", 7)) {
+                    if (!ap_casecmpstrn(token, "max-age", 7)) {
                         if (token[7] == '=') {
                             max_age = 1;
                             max_age_value = apr_atoi64(token + 8);
@@ -679,14 +655,7 @@ static apr_status_t policy_maxage_out_filter(ap_filter_t *f,
                 }
                 case 's':
                 case 'S': {
-                    if (!strncmp(token, "s-maxage", 8)) {
-                        if (token[8] == '=') {
-                            s_maxage = 1;
-                            s_maxage_value = apr_atoi64(token + 9);
-                        }
-                        break;
-                    }
-                    else if (!strncasecmp(token, "s-maxage", 8)) {
+                    if (!ap_casecmpstrn(token, "s-maxage", 8)) {
                         if (token[8] == '=') {
                             s_maxage = 1;
                             s_maxage_value = apr_atoi64(token + 9);
diff --git a/server/mpm_unix.c b/server/mpm_unix.c
index 1a7f9359c7..b5f4874233 100644
--- a/server/mpm_unix.c
+++ b/server/mpm_unix.c
@@ -627,7 +627,7 @@ static apr_status_t dummy_connection(ap_pod_t *pod)
      * expensive to do correctly (performing a complete SSL handshake)
      * or cause log spam by doing incorrectly (simply sending EOF). */
     lp = ap_listeners;
-    while (lp && lp->protocol && strcasecmp(lp->protocol, "http") != 0) {
+    while (lp && lp->protocol && ap_casecmpstr(lp->protocol, "http") != 0) {
         lp = lp->next;
     }
     if (!lp) {
@@ -675,7 +675,7 @@ static apr_status_t dummy_connection(ap_pod_t *pod)
         return rv;
     }
 
-    if (lp->protocol && strcasecmp(lp->protocol, "https") == 0) {
+    if (lp->protocol && ap_casecmpstr(lp->protocol, "https") == 0) {
         /* Send a TLS 1.0 close_notify alert.  This is perhaps the
          * "least wrong" way to open and cleanly terminate an SSL
          * connection.  It should "work" without noisy error logs if
diff --git a/server/protocol.c b/server/protocol.c
index 810d3b056b..c471644b9c 100644
--- a/server/protocol.c
+++ b/server/protocol.c
@@ -526,7 +526,7 @@ AP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri)
     if (status == APR_SUCCESS) {
         /* if it has a scheme we may need to do absoluteURI vhost stuff */
         if (r->parsed_uri.scheme
-            && !strcasecmp(r->parsed_uri.scheme, ap_http_scheme(r))) {
+            && !ap_casecmpstr(r->parsed_uri.scheme, ap_http_scheme(r))) {
             r->hostname = r->parsed_uri.hostname;
         }
         else if (r->method_number == M_CONNECT) {
@@ -692,7 +692,7 @@ static int read_request_line(request_rec *r, apr_bucket_brigade *bb)
             }
         }
         if (3 == sscanf(r->protocol, "%4s/%u.%u", http, &major, &minor)
-            && (strcasecmp("http", http) == 0)
+            && (ap_casecmpstr("http", http) == 0)
             && (minor < HTTP_VERSION(1, 0)) ) { /* don't allow HTTP/0.1000 */
             r->proto_num = HTTP_VERSION(major, minor);
         }
@@ -1133,7 +1133,7 @@ request_rec *ap_read_request(conn_rec *conn)
              * the final encoding ...; the server MUST respond with the 400
              * (Bad Request) status code and then close the connection".
              */
-            if (!(strcasecmp(tenc, "chunked") == 0 /* fast path */
+            if (!(ap_casecmpstr(tenc, "chunked") == 0 /* fast path */
                     || ap_find_last_token(r->pool, tenc, "chunked"))) {
                 ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(02539)
                               "client sent unknown Transfer-Encoding "
@@ -1238,7 +1238,7 @@ request_rec *ap_read_request(conn_rec *conn)
          * unfortunately, to signal a poor man's mandatory extension that
          * the server must understand or return 417 Expectation Failed.
          */
-        if (strcasecmp(expect, "100-continue") == 0) {
+        if (ap_casecmpstr(expect, "100-continue") == 0) {
             r->expecting_100 = 1;
         }
         else {
@@ -1418,7 +1418,7 @@ AP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw)
                                               : "Authorization");
     const char *t;
 
-    if (!(t = ap_auth_type(r)) || strcasecmp(t, "Basic"))
+    if (!(t = ap_auth_type(r)) || ap_casecmpstr(t, "Basic"))
         return DECLINED;
 
     if (!ap_auth_name(r)) {
@@ -1432,7 +1432,7 @@ AP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw)
         return HTTP_UNAUTHORIZED;
     }
 
-    if (strcasecmp(ap_getword(r->pool, &auth_line, ' '), "Basic")) {
+    if (ap_casecmpstr(ap_getword(r->pool, &auth_line, ' '), "Basic")) {
         /* Client tried to authenticate using wrong auth scheme */
         ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(00573)
                       "client used wrong authentication scheme: %s", r->uri);
diff --git a/server/util.c b/server/util.c
index c4316c7bfb..76b7e2c957 100644
--- a/server/util.c
+++ b/server/util.c
@@ -1609,7 +1609,7 @@ AP_DECLARE(int) ap_find_token(apr_pool_t *p, const char *line, const char *tok)
         while (*s && !TEST_CHAR(*s, T_HTTP_TOKEN_STOP)) {
             ++s;
         }
-        if (!strncasecmp((const char *)start_token, (const char *)tok,
+        if (!ap_casecmpstrn((const char *)start_token, (const char *)tok,
                          s - start_token)) {
             return 1;
         }
@@ -1636,7 +1636,7 @@ AP_DECLARE(int) ap_find_last_token(apr_pool_t *p, const char *line,
         (lidx > 0 && !(apr_isspace(line[lidx - 1]) || line[lidx - 1] == ',')))
         return 0;
 
-    return (strncasecmp(&line[lidx], tok, tlen) == 0);
+    return (ap_casecmpstrn(&line[lidx], tok, tlen) == 0);
 }
 
 AP_DECLARE(char *) ap_escape_shell_cmd(apr_pool_t *p, const char *str)
@@ -2603,7 +2603,7 @@ AP_DECLARE(int) ap_parse_form_data(request_rec *r, ap_filter_t *f,
 
     /* sanity check - we only support forms for now */
     ct = apr_table_get(r->headers_in, "Content-Type");
-    if (!ct || strncasecmp("application/x-www-form-urlencoded", ct, 33)) {
+    if (!ct || ap_casecmpstrn("application/x-www-form-urlencoded", ct, 33)) {
         return ap_discard_request_body(r);
     }
 
diff --git a/server/util_expr_eval.c b/server/util_expr_eval.c
index 9b569bd132..08ba66a410 100644
--- a/server/util_expr_eval.c
+++ b/server/util_expr_eval.c
@@ -1710,13 +1710,13 @@ static int op_T(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
         return FALSE;
     case 'o':
     case 'O':
-        return strcasecmp(arg, "off") == 0 ? FALSE : TRUE;
+        return ap_casecmpstr(arg, "off") == 0 ? FALSE : TRUE;
     case 'n':
     case 'N':
-        return strcasecmp(arg, "no") == 0 ? FALSE : TRUE;
+        return ap_casecmpstr(arg, "no") == 0 ? FALSE : TRUE;
     case 'f':
     case 'F':
-        return strcasecmp(arg, "false") == 0 ? FALSE : TRUE;
+        return ap_casecmpstr(arg, "false") == 0 ? FALSE : TRUE;
     case '0':
         return arg[1] == '\0' ? FALSE : TRUE;
     default:
@@ -1824,7 +1824,7 @@ static int core_expr_lookup(ap_expr_lookup_parms *parms)
             while (prov->func) {
                 const char **name = prov->names;
                 while (*name) {
-                    if (strcasecmp(*name, parms->name) == 0) {
+                    if (ap_casecmpstr(*name, parms->name) == 0) {
                         *parms->func = prov->func;
                         *parms->data = name;
                         return OK;
@@ -1857,7 +1857,7 @@ static int core_expr_lookup(ap_expr_lookup_parms *parms)
                 if (parms->type == AP_EXPR_FUNC_OP_UNARY)
                     match = !strcmp(prov->name, parms->name);
                 else
-                    match = !strcasecmp(prov->name, parms->name);
+                    match = !ap_casecmpstr(prov->name, parms->name);
                 if (match) {
                     if ((parms->flags & AP_EXPR_FLAG_RESTRICTED)
                         && prov->restricted) {
diff --git a/server/util_script.c b/server/util_script.c
index 943957d1c9..651b119094 100644
--- a/server/util_script.c
+++ b/server/util_script.c
@@ -180,10 +180,10 @@ AP_DECLARE(void) ap_add_common_vars(request_rec *r)
          * for no particular reason.
          */
 
-        if (!strcasecmp(hdrs[i].key, "Content-type")) {
+        if (!ap_casecmpstr(hdrs[i].key, "Content-type")) {
             apr_table_addn(e, "CONTENT_TYPE", hdrs[i].val);
         }
-        else if (!strcasecmp(hdrs[i].key, "Content-length")) {
+        else if (!ap_casecmpstr(hdrs[i].key, "Content-length")) {
             apr_table_addn(e, "CONTENT_LENGTH", hdrs[i].val);
         }
         /*
@@ -192,8 +192,8 @@ AP_DECLARE(void) ap_add_common_vars(request_rec *r)
          * in the environment with "ps -e".  But, if you must...
          */
 #ifndef SECURITY_HOLE_PASS_AUTHORIZATION
-        else if (!strcasecmp(hdrs[i].key, "Authorization")
-                 || !strcasecmp(hdrs[i].key, "Proxy-Authorization")) {
+        else if (!ap_casecmpstr(hdrs[i].key, "Authorization")
+                 || !ap_casecmpstr(hdrs[i].key, "Proxy-Authorization")) {
             if (conf->cgi_pass_auth == AP_CGI_PASS_AUTH_ON) {
                 add_unless_null(e, http2env(r, hdrs[i].key), hdrs[i].val);
             }
@@ -597,7 +597,7 @@ AP_DECLARE(int) ap_scan_script_header_err_core_ex(request_rec *r, char *buffer,
             ++l;
         }
 
-        if (!strcasecmp(w, "Content-type")) {
+        if (!ap_casecmpstr(w, "Content-type")) {
             char *tmp;
 
             /* Nuke trailing whitespace */
@@ -615,7 +615,7 @@ AP_DECLARE(int) ap_scan_script_header_err_core_ex(request_rec *r, char *buffer,
          * If the script returned a specific status, that's what
          * we'll use - otherwise we assume 200 OK.
          */
-        else if (!strcasecmp(w, "Status")) {
+        else if (!ap_casecmpstr(w, "Status")) {
             r->status = cgi_status = atoi(l);
             if (!ap_is_HTTP_VALID_RESPONSE(cgi_status))
                 ap_log_rerror(SCRIPT_LOG_MARK, APLOG_ERR|APLOG_TOCLIENT, 0, r,
@@ -628,30 +628,30 @@ AP_DECLARE(int) ap_scan_script_header_err_core_ex(request_rec *r, char *buffer,
                                  apr_filepath_name_get(r->filename), l);
             r->status_line = apr_pstrdup(r->pool, l);
         }
-        else if (!strcasecmp(w, "Location")) {
+        else if (!ap_casecmpstr(w, "Location")) {
             apr_table_set(r->headers_out, w, l);
         }
-        else if (!strcasecmp(w, "Content-Length")) {
+        else if (!ap_casecmpstr(w, "Content-Length")) {
             apr_table_set(r->headers_out, w, l);
         }
-        else if (!strcasecmp(w, "Content-Range")) {
+        else if (!ap_casecmpstr(w, "Content-Range")) {
             apr_table_set(r->headers_out, w, l);
         }
-        else if (!strcasecmp(w, "Transfer-Encoding")) {
+        else if (!ap_casecmpstr(w, "Transfer-Encoding")) {
             apr_table_set(r->headers_out, w, l);
         }
-        else if (!strcasecmp(w, "ETag")) {
+        else if (!ap_casecmpstr(w, "ETag")) {
             apr_table_set(r->headers_out, w, l);
         }
         /*
          * If the script gave us a Last-Modified header, we can't just
          * pass it on blindly because of restrictions on future values.
          */
-        else if (!strcasecmp(w, "Last-Modified")) {
+        else if (!ap_casecmpstr(w, "Last-Modified")) {
             ap_update_mtime(r, apr_date_parse_http(l));
             ap_set_last_modified(r);
         }
-        else if (!strcasecmp(w, "Set-Cookie")) {
+        else if (!ap_casecmpstr(w, "Set-Cookie")) {
             apr_table_add(cookie_table, w, l);
         }
         else {
-- 
2.50.0