]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r291588, r291672 and r291914 from trunk; make mod_dir and mod_cache
authorColm MacCarthaigh <colm@apache.org>
Thu, 29 Sep 2005 12:20:54 +0000 (12:20 +0000)
committerColm MacCarthaigh <colm@apache.org>
Thu, 29 Sep 2005 12:20:54 +0000 (12:20 +0000)
play nice together.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@292423 13f79535-47bb-0310-9956-ffa450edef68

modules/cache/cache_storage.c
modules/cache/mod_cache.c
modules/cache/mod_cache.h
modules/mappers/mod_dir.c
server/request.c

index 5d781602702baca4ea26a79783b67be86fb58660..9c75db2997bd59cf9f4c158a827b08d041469d16 100644 (file)
@@ -66,7 +66,7 @@ int cache_remove_url(cache_request_rec *cache, apr_pool_t *p)
  * decide whether or not it wants to cache this particular entity.
  * If the size is unknown, a size of -1 should be set.
  */
-int cache_create_entity(request_rec *r, char *url, apr_off_t size)
+int cache_create_entity(request_rec *r, apr_off_t size)
 {
     cache_provider_list *list;
     cache_handle_t *h = apr_pcalloc(r->pool, sizeof(cache_handle_t));
index 0bd4d23663e3e1f1d157aae99dac1b8217c9686e..17e046dbee2632e2abba60fab0b501881790d458 100644 (file)
@@ -110,14 +110,15 @@ static int cache_url_handler(request_rec *r, int lookup)
         if (rv == DECLINED) {
             if (!lookup) {
                 ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
-                  "Adding CACHE_SAVE filter.");
+                  "Adding CACHE_SAVE filter for %s", r->uri);
 
                 /* add cache_save filter to cache this request */
                 ap_add_output_filter_handle(cache_save_filter_handle, NULL, r,
                                             r->connection);
 
                 ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
-                             "Adding CACHE_REMOVE_URL filter.");
+                             "Adding CACHE_REMOVE_URL filter for %s", 
+                             r->uri);
 
                 /* Add cache_remove_url filter to this request to remove a
                  * stale cache entry if needed. Also put the current cache
@@ -129,11 +130,17 @@ static int cache_url_handler(request_rec *r, int lookup)
                     ap_add_output_filter_handle(cache_remove_url_filter_handle, 
                                                 cache, r, r->connection);
             }
-            else if (cache->stale_headers) {
-                ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
-                  "Restoring request headers.");
-
-                r->headers_in = cache->stale_headers;
+            else {
+                if (cache->stale_headers) {
+                    ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, 
+                                 r->server, "Restoring request headers for %s", 
+                                 r->uri);
+
+                    r->headers_in = cache->stale_headers;
+                }
+                
+                /* Delete our per-request configuration. */
+                ap_set_module_config(r->request_config, &cache_module, NULL);
             }
         }
         else {
@@ -144,9 +151,29 @@ static int cache_url_handler(request_rec *r, int lookup)
         }
         return DECLINED;
     }
+    /* if we are a lookup, we are exiting soon one way or another; Restore
+     * the headers. */
+    if (lookup) {
+        if (cache->stale_headers) {
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, 
+                         "Restoring request headers.");
+            r->headers_in = cache->stale_headers;
+        }
+
+        /* Delete our per-request configuration. */
+        ap_set_module_config(r->request_config, &cache_module, NULL);
+    }
 
     rv = ap_meets_conditions(r);
     if (rv != OK) {
+        /* If we are a lookup, we have to return DECLINED as we have no
+         * way of knowing if we will be able to serve the content. 
+         */
+        if (lookup) {
+            return DECLINED;
+        }
+
         /* Return cached status. */
         return rv;
     }
@@ -245,7 +272,6 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
     request_rec *r = f->r;
     cache_request_rec *cache;
     cache_server_conf *conf;
-    char *url = r->unparsed_uri;
     const char *cc_out, *cl;
     const char *exps, *lastmods, *dates, *etag;
     apr_time_t exp, date, lastmod, now;
@@ -445,7 +471,8 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
 
     if (reason) {
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-                     "cache: %s not cached. Reason: %s", url, reason);
+                     "cache: %s not cached. Reason: %s", r->unparsed_uri, 
+                     reason);
 
         /* remove this filter from the chain */
         ap_remove_output_filter(f);
@@ -531,7 +558,7 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
 
     /* no cache handle, create a new entity */
     if (!cache->handle) {
-        rv = cache_create_entity(r, url, size);
+        rv = cache_create_entity(r, size);
         info = apr_pcalloc(r->pool, sizeof(cache_info));
         /* We only set info->status upon the initial creation. */
         info->status = r->status;
@@ -544,7 +571,7 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
     }
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-                 "cache: Caching url: %s", url);
+                 "cache: Caching url: %s", r->unparsed_uri);
 
     /* We are actually caching this response. So it does not
      * make sense to remove this entity any more.
index 744f7cc5b1266e9b6661493e2ced0bbbba585558..8e4bea8499832733a2fd9b563d9ac8d869cba395 100644 (file)
@@ -212,15 +212,15 @@ struct cache_provider_list {
 
 /* per request cache information */
 typedef struct {
-    cache_provider_list *providers;         /* possible cache providers */
-    const cache_provider *provider;         /* current cache provider */
-    const char *provider_name;              /* current cache provider name */
-    int fresh;                         /* is the entitey fresh? */
-    cache_handle_t *handle;            /* current cache handle */
-    cache_handle_t *stale_handle;      /* stale cache handle */
-    apr_table_t *stale_headers;                /* original request headers. */
-    int in_checked;                    /* CACHE_SAVE must cache the entity */
-    int block_response;                        /* CACHE_SAVE must block response. */
+    cache_provider_list *providers;     /* possible cache providers */
+    const cache_provider *provider;     /* current cache provider */
+    const char *provider_name;          /* current cache provider name */
+    int fresh;                          /* is the entitey fresh? */
+    cache_handle_t *handle;             /* current cache handle */
+    cache_handle_t *stale_handle;       /* stale cache handle */
+    apr_table_t *stale_headers;         /* original request headers. */
+    int in_checked;                     /* CACHE_SAVE must cache the entity */
+    int block_response;                 /* CACHE_SAVE must block response. */
     apr_bucket_brigade *saved_brigade;  /* copy of partial response */
     apr_off_t saved_size;               /* length of saved_brigade */
     apr_time_t exp;                     /* expiration */
@@ -274,7 +274,7 @@ CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool,
  * cache_storage.c
  */
 int cache_remove_url(cache_request_rec *cache, apr_pool_t *p);
-int cache_create_entity(request_rec *r, char *url, apr_off_t size);
+int cache_create_entity(request_rec *r, apr_off_t size);
 int cache_select(request_rec *r);
 apr_status_t cache_generate_key_default( request_rec *r, apr_pool_t*p, char**key );
 /**
index b0bc39a7dd0f654c90adf8bed2f7218fb8e4a2ad..c2dd0fb058bfd044dbc3e53f898db6251591033b 100644 (file)
@@ -182,8 +182,17 @@ static int fixup_dir(request_rec *r)
 
         rr = ap_sub_req_lookup_uri(name_ptr, r, NULL);
 
-        /* XXX: (filetype == APR_REG) - we can't use a non-file index??? */
-        if (   rr->status == HTTP_OK
+        /* The sub request lookup is very liberal, and the core map_to_storage
+         * handler will almost always result in HTTP_OK as /foo/index.html
+         * may be /foo with PATH_INFO="/index.html", or even / with 
+         * PATH_INFO="/foo/index.html". To get around this we insist that the
+         * the index be a regular filetype.
+         *
+         * Another reason is that the core handler also makes the assumption 
+         * that if r->finfo is still NULL by the time it gets called, the 
+         * file does not exist.
+         */
+        if (rr->status == HTTP_OK
             && (   (rr->handler && !strcmp(rr->handler, "proxy-server"))
                 || rr->finfo.filetype == APR_REG)) {
             ap_internal_fast_redirect(rr, r);
index c26c8612a2a99cefd7e617484c5d74a0ae6ac171..b8ca6a435831edcd668c936dc8fc65a25c3aa04b 100644 (file)
@@ -1608,10 +1608,18 @@ AP_DECLARE(request_rec *) ap_sub_req_method_uri(const char *method,
     /* lookup_uri 
      * If the content can be served by the quick_handler, we can
      * safely bypass request_internal processing.
+     *
+     * If next_filter is NULL we are expecting to be 
+     * internal_fast_redirect'ed to the subrequest, or the subrequest will 
+     * never be invoked. We need to make sure that the quickhandler is not 
+     * invoked by any lookups. Since an internal_fast_redirect will always 
+     * occur too late for the quickhandler to handle the request.
      */
-    res = ap_run_quick_handler(rnew, 1);
+    if (next_filter) {
+        res = ap_run_quick_handler(rnew, 1);
+    }
 
-    if (res != OK) {
+    if (next_filter == NULL || res != OK) {
         if ((res = ap_process_request_internal(rnew))) {
             rnew->status = res;
         }