httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r1480283 - in /httpd/httpd/trunk/modules/cache: cache_storage.c cache_storage.h mod_cache.c
Date Wed, 08 May 2013 14:06:48 GMT
Author: minfrin
Date: Wed May  8 14:06:48 2013
New Revision: 1480283

URL: http://svn.apache.org/r1480283
Log:
Ensure that Warning headers are correctly handled as per RFC2616.

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

Modified: httpd/httpd/trunk/modules/cache/cache_storage.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_storage.c?rev=1480283&r1=1480282&r2=1480283&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_storage.c (original)
+++ httpd/httpd/trunk/modules/cache/cache_storage.c Wed May  8 14:06:48 2013
@@ -113,9 +113,30 @@ int cache_create_entity(cache_request_re
     return DECLINED;
 }
 
+static int filter_header_do(void *v, const char *key, const char *val)
+{
+    if ((*key == 'W' || *key == 'w') && !strcasecmp(key, "Warning")
+            && *val == '1') {
+        /* any stored Warning headers with warn-code 1xx (see section
+         * 14.46) MUST be deleted from the cache entry and the forwarded
+         * response.
+         */
+    }
+    else {
+        apr_table_addn(v, key, val);
+    }
+    return 1;
+}
 static int remove_header_do(void *v, const char *key, const char *val)
 {
-    apr_table_unset(v, key);
+    if ((*key == 'W' || *key == 'w') && !strcasecmp(key, "Warning")) {
+        /* any stored Warning headers with warn-code 2xx MUST be retained
+         * in the cache entry and the forwarded response.
+         */
+    }
+    else {
+        apr_table_unset(v, key);
+    }
     return 1;
 }
 static int add_header_do(void *v, const char *key, const char *val)
@@ -130,20 +151,25 @@ static int add_header_do(void *v, const 
  *
  * To complicate this, a header may be duplicated in either table. Should a
  * header exist in the top table, all matching headers will be removed from
- * the bottom table before the headers are combined.
+ * the bottom table before the headers are combined. The Warning headers are
+ * handled specially. Warnings are added rather than being replaced, while
+ * in the case of revalidation 1xx Warnings are stripped.
  *
  * The Content-Type and Last-Modified headers are then re-parsed and inserted
  * into the request.
  */
 void cache_accept_headers(cache_handle_t *h, request_rec *r, apr_table_t *top,
-        apr_table_t *bottom)
+        apr_table_t *bottom, int revalidation)
 {
     const char *v;
 
-    if (r->headers_out != bottom) {
+    if (revalidation) {
+        r->headers_out = apr_table_make(r->pool, 10);
+        apr_table_do(filter_header_do, r->headers_out, bottom, NULL);
+    }
+    else if (r->headers_out != bottom) {
         r->headers_out = apr_table_copy(r->pool, bottom);
     }
-
     apr_table_do(remove_header_do, r->headers_out, top, NULL);
     apr_table_do(add_header_do, r->headers_out, top, NULL);
 
@@ -372,7 +398,7 @@ int cache_select(cache_request_rec *cach
             }
 
             /* Okay, this response looks okay.  Merge in our stuff and go. */
-            cache_accept_headers(h, r, h->resp_hdrs, r->headers_out);
+            cache_accept_headers(h, r, h->resp_hdrs, r->headers_out, 0);
 
             cache->handle = h;
             return OK;

Modified: httpd/httpd/trunk/modules/cache/cache_storage.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_storage.h?rev=1480283&r1=1480282&r2=1480283&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_storage.h (original)
+++ httpd/httpd/trunk/modules/cache/cache_storage.h Wed May  8 14:06:48 2013
@@ -63,9 +63,10 @@ apr_status_t cache_generate_key_default(
  * @param r request_rec
  * @param top headers to be applied
  * @param bottom headers to be overwritten
+ * @param revalidation true if revalidation is taking place
  */
 void cache_accept_headers(cache_handle_t *h, request_rec *r, apr_table_t *top,
-        apr_table_t *bottom);
+        apr_table_t *bottom, int revalidation);
 
 #ifdef __cplusplus
 }

Modified: httpd/httpd/trunk/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache.c?rev=1480283&r1=1480282&r2=1480283&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.c Wed May  8 14:06:48 2013
@@ -1190,7 +1190,7 @@ static apr_status_t cache_save_filter(ap
         /* Merge in our cached headers.  However, keep any updated values. */
         /* take output, overlay on top of cached */
         cache_accept_headers(cache->handle, r, r->headers_out,
-                cache->handle->resp_hdrs);
+                cache->handle->resp_hdrs, 1);
 
         status = ap_meets_conditions(r);
         if (status != OK) {
@@ -1469,7 +1469,7 @@ static apr_status_t cache_save_filter(ap
         /* Merge in our cached headers.  However, keep any updated values. */
         /* take output, overlay on top of cached */
         cache_accept_headers(cache->handle, r, r->headers_out,
-                cache->handle->resp_hdrs);
+                cache->handle->resp_hdrs, 1);
     }
 
     /* Write away header information to cache. It is possible that we are



Mime
View raw message