mirror of
https://github.com/apache/httpd.git
synced 2025-08-06 11:06:17 +00:00
mod_cache: Use the actual URI path and query-string for identifying the
cached entity (key), such that rewrites are taken into account when running afterwards (CacheQuickHandler off). PR 21935. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1756553 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
4
CHANGES
4
CHANGES
@ -1,6 +1,10 @@
|
|||||||
-*- coding: utf-8 -*-
|
-*- coding: utf-8 -*-
|
||||||
Changes with Apache 2.5.0
|
Changes with Apache 2.5.0
|
||||||
|
|
||||||
|
*) mod_cache: Use the actual URI path and query-string for identifying the
|
||||||
|
cached entity (key), such that rewrites are taken into account when
|
||||||
|
running afterwards (CacheQuickHandler off). PR 21935. [Yann Ylavic]
|
||||||
|
|
||||||
*) mod_ssl: Fix quick renegotiation (OptRenegotiaton) with no intermediate
|
*) mod_ssl: Fix quick renegotiation (OptRenegotiaton) with no intermediate
|
||||||
in the client certificate chain. PR 55786. [Yann Ylavic]
|
in the client certificate chain. PR 55786. [Yann Ylavic]
|
||||||
|
|
||||||
|
46
modules/cache/cache_storage.c
vendored
46
modules/cache/cache_storage.c
vendored
@ -427,7 +427,9 @@ int cache_select(cache_request_rec *cache, request_rec *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static apr_status_t cache_canonicalise_key(request_rec *r, apr_pool_t* p,
|
static apr_status_t cache_canonicalise_key(request_rec *r, apr_pool_t* p,
|
||||||
const char *uri, apr_uri_t *parsed_uri, const char **key)
|
const char *uri, const char *query,
|
||||||
|
apr_uri_t *parsed_uri,
|
||||||
|
const char **key)
|
||||||
{
|
{
|
||||||
cache_server_conf *conf;
|
cache_server_conf *conf;
|
||||||
char *port_str, *hn, *lcs;
|
char *port_str, *hn, *lcs;
|
||||||
@ -563,7 +565,7 @@ static apr_status_t cache_canonicalise_key(request_rec *r, apr_pool_t* p,
|
|||||||
* if needed.
|
* if needed.
|
||||||
*/
|
*/
|
||||||
path = uri;
|
path = uri;
|
||||||
querystring = parsed_uri->query;
|
querystring = apr_pstrdup(p, query ? query : parsed_uri->query);
|
||||||
if (conf->ignore_session_id->nelts) {
|
if (conf->ignore_session_id->nelts) {
|
||||||
int i;
|
int i;
|
||||||
char **identifier;
|
char **identifier;
|
||||||
@ -588,7 +590,7 @@ static apr_status_t cache_canonicalise_key(request_rec *r, apr_pool_t* p,
|
|||||||
/*
|
/*
|
||||||
* Check if the identifier is in the querystring and cut it out.
|
* Check if the identifier is in the querystring and cut it out.
|
||||||
*/
|
*/
|
||||||
if (querystring) {
|
if (querystring && *querystring) {
|
||||||
/*
|
/*
|
||||||
* First check if the identifier is at the beginning of the
|
* First check if the identifier is at the beginning of the
|
||||||
* querystring and followed by a '='
|
* querystring and followed by a '='
|
||||||
@ -605,7 +607,7 @@ static apr_status_t cache_canonicalise_key(request_rec *r, apr_pool_t* p,
|
|||||||
* identifier with a '&' and append a '='
|
* identifier with a '&' and append a '='
|
||||||
*/
|
*/
|
||||||
complete = apr_pstrcat(p, "&", *identifier, "=", NULL);
|
complete = apr_pstrcat(p, "&", *identifier, "=", NULL);
|
||||||
param = strstr(querystring, complete);
|
param = ap_strstr_c(querystring, complete);
|
||||||
/* If we found something we are sitting on the '&' */
|
/* If we found something we are sitting on the '&' */
|
||||||
if (param) {
|
if (param) {
|
||||||
param++;
|
param++;
|
||||||
@ -669,7 +671,11 @@ static apr_status_t cache_canonicalise_key(request_rec *r, apr_pool_t* p,
|
|||||||
apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
|
apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
|
||||||
const char **key)
|
const char **key)
|
||||||
{
|
{
|
||||||
return cache_canonicalise_key(r, p, r->uri, &r->parsed_uri, key);
|
/* We want the actual query-string, which may differ from
|
||||||
|
* r->parsed_uri.query (immutable), so use "" (not NULL).
|
||||||
|
*/
|
||||||
|
const char *args = r->args ? r->args : "";
|
||||||
|
return cache_canonicalise_key(r, p, r->uri, args, &r->parsed_uri, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -709,12 +715,13 @@ int cache_invalidate(cache_request_rec *cache, request_rec *r)
|
|||||||
|
|
||||||
location = apr_table_get(r->headers_out, "Location");
|
location = apr_table_get(r->headers_out, "Location");
|
||||||
if (location) {
|
if (location) {
|
||||||
if (APR_SUCCESS != apr_uri_parse(r->pool, location, &location_uri)
|
if (apr_uri_parse(r->pool, location, &location_uri)
|
||||||
|| APR_SUCCESS
|
|| cache_canonicalise_key(r, r->pool,
|
||||||
!= cache_canonicalise_key(r, r->pool, location,
|
location, NULL,
|
||||||
&location_uri, &location_key)
|
&location_uri, &location_key)
|
||||||
|| !(r->parsed_uri.hostname && location_uri.hostname
|
|| !(r->parsed_uri.hostname
|
||||||
&& !strcmp(r->parsed_uri.hostname,
|
&& location_uri.hostname
|
||||||
|
&& !strcmp(r->parsed_uri.hostname,
|
||||||
location_uri.hostname))) {
|
location_uri.hostname))) {
|
||||||
location_key = NULL;
|
location_key = NULL;
|
||||||
}
|
}
|
||||||
@ -722,14 +729,15 @@ int cache_invalidate(cache_request_rec *cache, request_rec *r)
|
|||||||
|
|
||||||
content_location = apr_table_get(r->headers_out, "Content-Location");
|
content_location = apr_table_get(r->headers_out, "Content-Location");
|
||||||
if (content_location) {
|
if (content_location) {
|
||||||
if (APR_SUCCESS
|
if (apr_uri_parse(r->pool, content_location,
|
||||||
!= apr_uri_parse(r->pool, content_location,
|
&content_location_uri)
|
||||||
&content_location_uri)
|
|| cache_canonicalise_key(r, r->pool,
|
||||||
|| APR_SUCCESS
|
content_location, NULL,
|
||||||
!= cache_canonicalise_key(r, r->pool, content_location,
|
&content_location_uri,
|
||||||
&content_location_uri, &content_location_key)
|
&content_location_key)
|
||||||
|| !(r->parsed_uri.hostname && content_location_uri.hostname
|
|| !(r->parsed_uri.hostname
|
||||||
&& !strcmp(r->parsed_uri.hostname,
|
&& content_location_uri.hostname
|
||||||
|
&& !strcmp(r->parsed_uri.hostname,
|
||||||
content_location_uri.hostname))) {
|
content_location_uri.hostname))) {
|
||||||
content_location_key = NULL;
|
content_location_key = NULL;
|
||||||
}
|
}
|
||||||
|
14
modules/cache/cache_util.c
vendored
14
modules/cache/cache_util.c
vendored
@ -31,8 +31,9 @@ extern module AP_MODULE_DECLARE_DATA cache_module;
|
|||||||
* in "filter". All but the path comparisons are case-insensitive.
|
* in "filter". All but the path comparisons are case-insensitive.
|
||||||
*/
|
*/
|
||||||
static int uri_meets_conditions(const apr_uri_t *filter, const int pathlen,
|
static int uri_meets_conditions(const apr_uri_t *filter, const int pathlen,
|
||||||
const apr_uri_t *url)
|
request_rec *r)
|
||||||
{
|
{
|
||||||
|
const apr_uri_t *url = &r->parsed_uri;
|
||||||
|
|
||||||
/* Scheme, hostname port and local part. The filter URI and the
|
/* Scheme, hostname port and local part. The filter URI and the
|
||||||
* URI we test may have the following shapes:
|
* URI we test may have the following shapes:
|
||||||
@ -113,7 +114,7 @@ static int uri_meets_conditions(const apr_uri_t *filter, const int pathlen,
|
|||||||
/* For HTTP caching purposes, an empty (NULL) path is equivalent to
|
/* For HTTP caching purposes, an empty (NULL) path is equivalent to
|
||||||
* a single "/" path. RFCs 3986/2396
|
* a single "/" path. RFCs 3986/2396
|
||||||
*/
|
*/
|
||||||
if (!url->path) {
|
if (!r->uri) {
|
||||||
if (*filter->path == '/' && pathlen == 1) {
|
if (*filter->path == '/' && pathlen == 1) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -125,7 +126,7 @@ static int uri_meets_conditions(const apr_uri_t *filter, const int pathlen,
|
|||||||
/* Url has met all of the filter conditions so far, determine
|
/* Url has met all of the filter conditions so far, determine
|
||||||
* if the paths match.
|
* if the paths match.
|
||||||
*/
|
*/
|
||||||
return !strncmp(filter->path, url->path, pathlen);
|
return !strncmp(filter->path, r->uri, pathlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cache_provider_list *get_provider(request_rec *r, struct cache_enable *ent,
|
static cache_provider_list *get_provider(request_rec *r, struct cache_enable *ent,
|
||||||
@ -167,8 +168,7 @@ static cache_provider_list *get_provider(request_rec *r, struct cache_enable *en
|
|||||||
}
|
}
|
||||||
|
|
||||||
cache_provider_list *cache_get_providers(request_rec *r,
|
cache_provider_list *cache_get_providers(request_rec *r,
|
||||||
cache_server_conf *conf,
|
cache_server_conf *conf)
|
||||||
apr_uri_t uri)
|
|
||||||
{
|
{
|
||||||
cache_dir_conf *dconf = ap_get_module_config(r->per_dir_config, &cache_module);
|
cache_dir_conf *dconf = ap_get_module_config(r->per_dir_config, &cache_module);
|
||||||
cache_provider_list *providers = NULL;
|
cache_provider_list *providers = NULL;
|
||||||
@ -183,7 +183,7 @@ cache_provider_list *cache_get_providers(request_rec *r,
|
|||||||
for (i = 0; i < conf->cachedisable->nelts; i++) {
|
for (i = 0; i < conf->cachedisable->nelts; i++) {
|
||||||
struct cache_disable *ent =
|
struct cache_disable *ent =
|
||||||
(struct cache_disable *)conf->cachedisable->elts;
|
(struct cache_disable *)conf->cachedisable->elts;
|
||||||
if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, &uri)) {
|
if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, r)) {
|
||||||
/* Stop searching now. */
|
/* Stop searching now. */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ cache_provider_list *cache_get_providers(request_rec *r,
|
|||||||
for (i = 0; i < conf->cacheenable->nelts; i++) {
|
for (i = 0; i < conf->cacheenable->nelts; i++) {
|
||||||
struct cache_enable *ent =
|
struct cache_enable *ent =
|
||||||
(struct cache_enable *)conf->cacheenable->elts;
|
(struct cache_enable *)conf->cacheenable->elts;
|
||||||
if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, &uri)) {
|
if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, r)) {
|
||||||
providers = get_provider(r, &ent[i], providers);
|
providers = get_provider(r, &ent[i], providers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
modules/cache/cache_util.h
vendored
2
modules/cache/cache_util.h
vendored
@ -300,7 +300,7 @@ apr_status_t cache_remove_lock(cache_server_conf *conf,
|
|||||||
cache_request_rec *cache, request_rec *r, apr_bucket_brigade *bb);
|
cache_request_rec *cache, request_rec *r, apr_bucket_brigade *bb);
|
||||||
|
|
||||||
cache_provider_list *cache_get_providers(request_rec *r,
|
cache_provider_list *cache_get_providers(request_rec *r,
|
||||||
cache_server_conf *conf, apr_uri_t uri);
|
cache_server_conf *conf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a value from a table, where the table may contain multiple
|
* Get a value from a table, where the table may contain multiple
|
||||||
|
4
modules/cache/mod_cache.c
vendored
4
modules/cache/mod_cache.c
vendored
@ -103,7 +103,7 @@ static int cache_quick_handler(request_rec *r, int lookup)
|
|||||||
/*
|
/*
|
||||||
* Which cache module (if any) should handle this request?
|
* Which cache module (if any) should handle this request?
|
||||||
*/
|
*/
|
||||||
if (!(providers = cache_get_providers(r, conf, r->parsed_uri))) {
|
if (!(providers = cache_get_providers(r, conf))) {
|
||||||
return DECLINED;
|
return DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ static int cache_handler(request_rec *r)
|
|||||||
/*
|
/*
|
||||||
* Which cache module (if any) should handle this request?
|
* Which cache module (if any) should handle this request?
|
||||||
*/
|
*/
|
||||||
if (!(providers = cache_get_providers(r, conf, r->parsed_uri))) {
|
if (!(providers = cache_get_providers(r, conf))) {
|
||||||
return DECLINED;
|
return DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user