Commit 2b2c19a7 authored by Graham Leggett's avatar Graham Leggett
Browse files

mod_cache: Remove ap_cache_liststr(), it duplicates ap_find_token().


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1209798 13f79535-47bb-0310-9956-ffa450edef68
parent 38a56d86
Loading
Loading
Loading
Loading
+0 −103
Changes for modules/cache/cache_util.c: 0 added lines, 103 removed lines.
Original line number Diff line number Diff line
@@ -737,109 +737,6 @@ int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache,

}

/*
 * list is a comma-separated list of case-insensitive tokens, with
 * optional whitespace around the tokens.
 * The return returns 1 if the token val is found in the list, or 0
 * otherwise.
 */
CACHE_DECLARE(int) ap_cache_liststr(apr_pool_t *p, const char *list,
                                    const char *key, char **val)
{
    apr_size_t key_len;
    const char *next;

    if (!list) {
        return 0;
    }

    key_len = strlen(key);
    next = list;

    for (;;) {

        /* skip whitespace and commas to find the start of the next key */
        while (*next && (apr_isspace(*next) || (*next == ','))) {
            next++;
        }

        if (!*next) {
            return 0;
        }

        if (!strncasecmp(next, key, key_len)) {
            /* this field matches the key (though it might just be
             * a prefix match, so make sure the match is followed
             * by either a space or an equals sign)
             */
            next += key_len;
            if (!*next || (*next == '=') || apr_isspace(*next) ||
                (*next == ',')) {
                /* valid match */
                if (val) {
                    while (*next && (*next != '=') && (*next != ',')) {
                        next++;
                    }
                    if (*next == '=') {
                        next++;
                        while (*next && apr_isspace(*next )) {
                            next++;
                        }
                        if (!*next) {
                            *val = NULL;
                        }
                        else {
                            const char *val_start = next;
                            while (*next && !apr_isspace(*next) &&
                                   (*next != ',')) {
                                /* EAT QUOTED STRING */
                                if (*next == '"' || *next == '\'') {
                                    char delim = *next;
                                    while (*++next != delim) {
                                        if (!*next) {
                                            return 0;
                                        }
                                        else if (*next == '\\') {
                                            ++next;
                                        }
                                    }
                                }
                                next++;
                            }
                            *val = apr_pstrmemdup(p, val_start,
                                                  next - val_start);
                        }
                    }
                    else {
                        *val = NULL;
                    }
                }
                return 1;
            }
        }

        /* skip to the next field */
        do {
            /* EAT QUOTED STRING */
            if (*next == '"' || *next == '\'') {
                char delim = *next;
                while (*++next != delim) {
                    if (!*next) {
                        return 0;
                    }
                    else if (*next == '\\') {
                        ++next;
                    }
                }
            }
            next++;
            if (!*next) {
                return 0;
            }
        } while (*next != ',');
    }
}

/* return each comma separated token, one at a time */
CACHE_DECLARE(const char *)ap_cache_tokstr(apr_pool_t *p, const char *list,
                                           const char **str)
+1 −3
Changes for modules/cache/mod_cache.c: 1 added line, 3 removed lines.
Original line number Diff line number Diff line
@@ -1014,9 +1014,7 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
         */
        reason = "Authorization required";
    }
    else if (ap_cache_liststr(NULL,
                              apr_table_get(r->headers_out, "Vary"),
                              "*", NULL)) {
    else if (ap_find_token(NULL, apr_table_get(r->headers_out, "Vary"), "*")) {
        reason = "Vary header contains '*'";
    }
    else if (apr_table_get(r->subprocess_env, "no-cache") != NULL) {
+0 −2
Changes for modules/cache/mod_cache.h: 0 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -136,8 +136,6 @@ CACHE_DECLARE(void) ap_cache_usec2hex(apr_time_t j, char *y);
CACHE_DECLARE(char *) ap_cache_generate_name(apr_pool_t *p, int dirlevels,
                                             int dirlength,
                                             const char *name);
CACHE_DECLARE(int) ap_cache_liststr(apr_pool_t *p, const char *list,
                                    const char *key, char **val);
CACHE_DECLARE(const char *)ap_cache_tokstr(apr_pool_t *p, const char *list, const char **str);

/* Create a new table consisting of those elements from an