httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stri...@apache.org
Subject svn commit: r156330 - in httpd/httpd/trunk/modules/cache: cache_storage.c mod_cache.c
Date Sun, 06 Mar 2005 18:57:24 GMT
Author: striker
Date: Sun Mar  6 10:57:22 2005
New Revision: 156330

URL: http://svn.apache.org/viewcvs?view=rev&rev=156330
Log:
More mod_cache tweakage...

* modules/cache/mod_cache.c

  (cache_save_filter): Instead of unconditionally returning a 304 when
   the original request was conditional and we issued a cache revalidating
   request, handle the request as if it came in while our cache was
   still valid.


* modules/cache/cache_storage.c

  (cache_select_url): Strip off the conditional headers from the original
   request, prior to adding our own for the purpose of revalidating our
   cached response.

Modified:
    httpd/httpd/trunk/modules/cache/cache_storage.c
    httpd/httpd/trunk/modules/cache/mod_cache.c

Modified: httpd/httpd/trunk/modules/cache/cache_storage.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/cache/cache_storage.c?view=diff&r1=156329&r2=156330
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_storage.c (original)
+++ httpd/httpd/trunk/modules/cache/cache_storage.c Sun Mar  6 10:57:22 2005
@@ -256,16 +256,26 @@
                 const char *etag, *lastmod;
 
                 /* Make response into a conditional */
+                cache->stale_headers = apr_table_copy(r->pool,
+                                                      r->headers_in);
+
+                /* We can only revalidate with our own conditionals: remove the
+                 * conditions from the original request.
+                 */
+                apr_table_unset(r->headers_in, "If-Match");
+                apr_table_unset(r->headers_in, "If-Modified-Since");
+                apr_table_unset(r->headers_in, "If-None-Match");
+                apr_table_unset(r->headers_in, "If-Range");
+                apr_table_unset(r->headers_in, "If-Unmodified-Since");
 
-                /* FIXME: What if the request is already conditional? */
                 etag = apr_table_get(h->resp_hdrs, "ETag");
                 lastmod = apr_table_get(h->resp_hdrs, "Last-Modified");
 
                 if (etag || lastmod) {
-                    /* If we have a cached etag and/or Last-Modified */
+                    /* If we have a cached etag and/or Last-Modified add in
+                     * our own conditionals.
+                     */
 
-                    cache->stale_headers = apr_table_copy(r->pool,
-                                                          r->headers_in);
                     if (etag) {
                         apr_table_set(r->headers_in, "If-None-Match", etag);
                     }

Modified: httpd/httpd/trunk/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/cache/mod_cache.c?view=diff&r1=156329&r2=156330
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.c Sun Mar  6 10:57:22 2005
@@ -688,22 +688,25 @@
 
     /* Did we just update the cached headers on a revalidated response?
      *
-     * If so, we can now decide what to serve to the client:
-     * - If the original request was conditional and is satisified, send 304.
-     * - Otherwise, send the cached body.
-    */
+     * If so, we can now decide what to serve to the client.  This is done in
+     * the same way as with a regular response, but conditions are now checked
+     * against the cached or merged response headers.
+     */
     if (rv == APR_SUCCESS && cache->stale_handle) {
         apr_bucket_brigade *bb;
         apr_bucket *bkt;
+        int status;
 
         bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
 
-        /* Were we initially a conditional request? */
-        if (ap_cache_request_is_conditional(cache->stale_headers)) {
-            /* FIXME: We must ensure that the request meets conditions. */
-
-            /* Set the status to be a 304. */
-            r->status = HTTP_NOT_MODIFIED;
+        /* Restore the original request headers and see if we need to
+         * return anything else than the cached response (ie. the original
+         * request was conditional).
+         */
+        r->headers_in = cache->stale_headers;
+        status = ap_meets_conditions(r);
+        if (status != OK) {
+            r->status = status;
 
             bkt = apr_bucket_flush_create(bb->bucket_alloc);
             APR_BRIGADE_INSERT_TAIL(bb, bkt);



Mime
View raw message