View | Details | Raw Unified | Return to bug 21935
Collapse All | Expand All

(-)modules/cache/cache_storage.c (-19 / +24 lines)
Lines 427-433 int cache_select(cache_request_rec *cache, request Link Here
427
}
427
}
428
428
429
static apr_status_t cache_canonicalise_key(request_rec *r, apr_pool_t* p,
429
static apr_status_t cache_canonicalise_key(request_rec *r, apr_pool_t* p,
430
        const char *uri, apr_uri_t *parsed_uri, const char **key)
430
                                           const char *uri, const char *query,
431
                                           apr_uri_t *parsed_uri,
432
                                           const char **key)
431
{
433
{
432
    cache_server_conf *conf;
434
    cache_server_conf *conf;
433
    char *port_str, *hn, *lcs;
435
    char *port_str, *hn, *lcs;
Lines 563-569 static apr_status_t cache_canonicalise_key(request Link Here
563
     * if needed.
565
     * if needed.
564
     */
566
     */
565
    path = uri;
567
    path = uri;
566
    querystring = parsed_uri->query;
568
    querystring = apr_pstrdup(p, query ? query : parsed_uri->query);
567
    if (conf->ignore_session_id->nelts) {
569
    if (conf->ignore_session_id->nelts) {
568
        int i;
570
        int i;
569
        char **identifier;
571
        char **identifier;
Lines 588-594 static apr_status_t cache_canonicalise_key(request Link Here
588
            /*
590
            /*
589
             * Check if the identifier is in the querystring and cut it out.
591
             * Check if the identifier is in the querystring and cut it out.
590
             */
592
             */
591
            if (querystring) {
593
            if (querystring && *querystring) {
592
                /*
594
                /*
593
                 * First check if the identifier is at the beginning of the
595
                 * First check if the identifier is at the beginning of the
594
                 * querystring and followed by a '='
596
                 * querystring and followed by a '='
Lines 605-611 static apr_status_t cache_canonicalise_key(request Link Here
605
                     * identifier with a '&' and append a '='
607
                     * identifier with a '&' and append a '='
606
                     */
608
                     */
607
                    complete = apr_pstrcat(p, "&", *identifier, "=", NULL);
609
                    complete = apr_pstrcat(p, "&", *identifier, "=", NULL);
608
                    param = strstr(querystring, complete);
610
                    param = ap_strstr_c(querystring, complete);
609
                    /* If we found something we are sitting on the '&' */
611
                    /* If we found something we are sitting on the '&' */
610
                    if (param) {
612
                    if (param) {
611
                        param++;
613
                        param++;
Lines 669-675 static apr_status_t cache_canonicalise_key(request Link Here
669
apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
671
apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
670
        const char **key)
672
        const char **key)
671
{
673
{
672
    return cache_canonicalise_key(r, p, r->uri, &r->parsed_uri, key);
674
    const char *args = r->args ? r->args : "";
675
    return cache_canonicalise_key(r, p, r->uri, args, &r->parsed_uri, key);
673
}
676
}
674
677
675
/*
678
/*
Lines 709-720 int cache_invalidate(cache_request_rec *cache, req Link Here
709
712
710
    location = apr_table_get(r->headers_out, "Location");
713
    location = apr_table_get(r->headers_out, "Location");
711
    if (location) {
714
    if (location) {
712
        if (APR_SUCCESS != apr_uri_parse(r->pool, location, &location_uri)
715
        if (apr_uri_parse(r->pool, location, &location_uri)
713
                || APR_SUCCESS
716
                || cache_canonicalise_key(r, r->pool,
714
                        != cache_canonicalise_key(r, r->pool, location,
717
                                          location, NULL,
715
                                &location_uri, &location_key)
718
                                          &location_uri, &location_key)
716
                || !(r->parsed_uri.hostname && location_uri.hostname
719
                || !(r->parsed_uri.hostname
717
                        && !strcmp(r->parsed_uri.hostname,
720
                     && location_uri.hostname
721
                     && !strcmp(r->parsed_uri.hostname,
718
                                location_uri.hostname))) {
722
                                location_uri.hostname))) {
719
            location_key = NULL;
723
            location_key = NULL;
720
        }
724
        }
Lines 722-735 int cache_invalidate(cache_request_rec *cache, req Link Here
722
726
723
    content_location = apr_table_get(r->headers_out, "Content-Location");
727
    content_location = apr_table_get(r->headers_out, "Content-Location");
724
    if (content_location) {
728
    if (content_location) {
725
        if (APR_SUCCESS
729
        if (apr_uri_parse(r->pool, content_location,
726
                != apr_uri_parse(r->pool, content_location,
730
                          &content_location_uri)
727
                        &content_location_uri)
731
                || cache_canonicalise_key(r, r->pool,
728
                || APR_SUCCESS
732
                                          content_location, NULL,
729
                        != cache_canonicalise_key(r, r->pool, content_location,
733
                                          &content_location_uri,
730
                                &content_location_uri, &content_location_key)
734
                                          &content_location_key)
731
                || !(r->parsed_uri.hostname && content_location_uri.hostname
735
                || !(r->parsed_uri.hostname
732
                        && !strcmp(r->parsed_uri.hostname,
736
                     && content_location_uri.hostname
737
                     && !strcmp(r->parsed_uri.hostname,
733
                                content_location_uri.hostname))) {
738
                                content_location_uri.hostname))) {
734
            content_location_key = NULL;
739
            content_location_key = NULL;
735
        }
740
        }
(-)modules/cache/cache_util.c (-7 / +7 lines)
Lines 31-38 extern module AP_MODULE_DECLARE_DATA cache_module; Link Here
31
 * in "filter". All but the path comparisons are case-insensitive.
31
 * in "filter". All but the path comparisons are case-insensitive.
32
 */
32
 */
33
static int uri_meets_conditions(const apr_uri_t *filter, const int pathlen,
33
static int uri_meets_conditions(const apr_uri_t *filter, const int pathlen,
34
                                const apr_uri_t *url)
34
                                request_rec *r)
35
{
35
{
36
    const apr_uri_t *url = &r->parsed_uri;
36
37
37
    /* Scheme, hostname port and local part. The filter URI and the
38
    /* Scheme, hostname port and local part. The filter URI and the
38
     * URI we test may have the following shapes:
39
     * URI we test may have the following shapes:
Lines 113-119 static int uri_meets_conditions(const apr_uri_t *f Link Here
113
    /* For HTTP caching purposes, an empty (NULL) path is equivalent to
114
    /* For HTTP caching purposes, an empty (NULL) path is equivalent to
114
     * a single "/" path. RFCs 3986/2396
115
     * a single "/" path. RFCs 3986/2396
115
     */
116
     */
116
    if (!url->path) {
117
    if (!r->uri) {
117
        if (*filter->path == '/' && pathlen == 1) {
118
        if (*filter->path == '/' && pathlen == 1) {
118
            return 1;
119
            return 1;
119
        }
120
        }
Lines 125-131 static int uri_meets_conditions(const apr_uri_t *f Link Here
125
    /* Url has met all of the filter conditions so far, determine
126
    /* Url has met all of the filter conditions so far, determine
126
     * if the paths match.
127
     * if the paths match.
127
     */
128
     */
128
    return !strncmp(filter->path, url->path, pathlen);
129
    return !strncmp(filter->path, r->uri, pathlen);
129
}
130
}
130
131
131
static cache_provider_list *get_provider(request_rec *r, struct cache_enable *ent,
132
static cache_provider_list *get_provider(request_rec *r, struct cache_enable *ent,
Lines 167-174 static cache_provider_list *get_provider(request_r Link Here
167
}
168
}
168
169
169
cache_provider_list *cache_get_providers(request_rec *r,
170
cache_provider_list *cache_get_providers(request_rec *r,
170
        cache_server_conf *conf,
171
                                         cache_server_conf *conf)
171
        apr_uri_t uri)
172
{
172
{
173
    cache_dir_conf *dconf = ap_get_module_config(r->per_dir_config, &cache_module);
173
    cache_dir_conf *dconf = ap_get_module_config(r->per_dir_config, &cache_module);
174
    cache_provider_list *providers = NULL;
174
    cache_provider_list *providers = NULL;
Lines 183-189 cache_provider_list *cache_get_providers(request_r Link Here
183
    for (i = 0; i < conf->cachedisable->nelts; i++) {
183
    for (i = 0; i < conf->cachedisable->nelts; i++) {
184
        struct cache_disable *ent =
184
        struct cache_disable *ent =
185
                               (struct cache_disable *)conf->cachedisable->elts;
185
                               (struct cache_disable *)conf->cachedisable->elts;
186
        if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, &uri)) {
186
        if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, r)) {
187
            /* Stop searching now. */
187
            /* Stop searching now. */
188
            return NULL;
188
            return NULL;
189
        }
189
        }
Lines 200-206 cache_provider_list *cache_get_providers(request_r Link Here
200
    for (i = 0; i < conf->cacheenable->nelts; i++) {
200
    for (i = 0; i < conf->cacheenable->nelts; i++) {
201
        struct cache_enable *ent =
201
        struct cache_enable *ent =
202
                                (struct cache_enable *)conf->cacheenable->elts;
202
                                (struct cache_enable *)conf->cacheenable->elts;
203
        if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, &uri)) {
203
        if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, r)) {
204
            providers = get_provider(r, &ent[i], providers);
204
            providers = get_provider(r, &ent[i], providers);
205
        }
205
        }
206
    }
206
    }
(-)modules/cache/cache_util.h (-1 / +1 lines)
Lines 300-306 apr_status_t cache_remove_lock(cache_server_conf * Link Here
300
        cache_request_rec *cache, request_rec *r, apr_bucket_brigade *bb);
300
        cache_request_rec *cache, request_rec *r, apr_bucket_brigade *bb);
301
301
302
cache_provider_list *cache_get_providers(request_rec *r,
302
cache_provider_list *cache_get_providers(request_rec *r,
303
        cache_server_conf *conf, apr_uri_t uri);
303
                                         cache_server_conf *conf);
304
304
305
/**
305
/**
306
 * Get a value from a table, where the table may contain multiple
306
 * Get a value from a table, where the table may contain multiple
(-)modules/cache/mod_cache.c (-2 / +2 lines)
Lines 103-109 static int cache_quick_handler(request_rec *r, int Link Here
103
    /*
103
    /*
104
     * Which cache module (if any) should handle this request?
104
     * Which cache module (if any) should handle this request?
105
     */
105
     */
106
    if (!(providers = cache_get_providers(r, conf, r->parsed_uri))) {
106
    if (!(providers = cache_get_providers(r, conf))) {
107
        return DECLINED;
107
        return DECLINED;
108
    }
108
    }
109
109
Lines 413-419 static int cache_handler(request_rec *r) Link Here
413
    /*
413
    /*
414
     * Which cache module (if any) should handle this request?
414
     * Which cache module (if any) should handle this request?
415
     */
415
     */
416
    if (!(providers = cache_get_providers(r, conf, r->parsed_uri))) {
416
    if (!(providers = cache_get_providers(r, conf))) {
417
        return DECLINED;
417
        return DECLINED;
418
    }
418
    }
419
419

Return to bug 21935