Return-Path: X-Original-To: apmail-httpd-cvs-archive@www.apache.org Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0D3B811385 for ; Wed, 30 Apr 2014 14:26:13 +0000 (UTC) Received: (qmail 19869 invoked by uid 500); 30 Apr 2014 14:26:11 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 19770 invoked by uid 500); 30 Apr 2014 14:26:10 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 19763 invoked by uid 99); 30 Apr 2014 14:26:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Apr 2014 14:26:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Apr 2014 14:26:09 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 60CF623888E4; Wed, 30 Apr 2014 14:25:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1591312 - in /httpd/httpd/trunk: CHANGES modules/cache/mod_cache.c Date: Wed, 30 Apr 2014 14:25:46 -0000 To: cvs@httpd.apache.org From: ylavic@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140430142546.60CF623888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ylavic Date: Wed Apr 30 14:25:45 2014 New Revision: 1591312 URL: http://svn.apache.org/r1591312 Log: mod_cache: Don't add cached/revalidated entity headers to a 304 response. PR 55547. When the conditional request meets the conditions of the stale then revalidated entry, the forwarded 304 response includes the entity headers merged from the cached headers (before updating the entry). Strip them before returning a 304. Since the entity headers are stripped elsewhere, factorize the code using a new table (MOD_CACHE_ENTITY_HEADERS[]) containing these headers's names. Modified: httpd/httpd/trunk/CHANGES httpd/httpd/trunk/modules/cache/mod_cache.c Modified: httpd/httpd/trunk/CHANGES URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1591312&r1=1591311&r2=1591312&view=diff ============================================================================== --- httpd/httpd/trunk/CHANGES [utf-8] (original) +++ httpd/httpd/trunk/CHANGES [utf-8] Wed Apr 30 14:25:45 2014 @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_cache: Don't add cached/revalidated entity headers to a 304 response. + PR 55547. [Yann Ylavic] + *) mod_cache: Retry unconditional request with the full URL (including the query-string) when the origin server's 304 response does not match the conditions used to revalidate the stale entry. [Yann Ylavic]. Modified: httpd/httpd/trunk/modules/cache/mod_cache.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache.c?rev=1591312&r1=1591311&r2=1591312&view=diff ============================================================================== --- httpd/httpd/trunk/modules/cache/mod_cache.c (original) +++ httpd/httpd/trunk/modules/cache/mod_cache.c Wed Apr 30 14:25:45 2014 @@ -36,6 +36,22 @@ static ap_filter_rec_t *cache_out_subreq static ap_filter_rec_t *cache_remove_url_filter_handle; static ap_filter_rec_t *cache_invalidate_filter_handle; +/** + * Entity headers' names + */ +static const char *MOD_CACHE_ENTITY_HEADERS[] = { + "Allow", + "Content-Encoding", + "Content-Language", + "Content-Length", + "Content-Location", + "Content-MD5", + "Content-Range", + "Content-Type", + "Last-Modified", + NULL +}; + /* * CACHE handler * ------------- @@ -802,7 +818,7 @@ static apr_status_t cache_save_filter(ap apr_time_t exp, date, lastmod, now; apr_off_t size = -1; cache_info *info = NULL; - const char *reason; + const char *reason, **eh; apr_pool_t *p; apr_bucket *e; apr_table_t *headers; @@ -1150,14 +1166,9 @@ static apr_status_t cache_save_filter(ap * inconsistencies between cached entity-bodies and updated headers. */ if (r->status == HTTP_NOT_MODIFIED) { - apr_table_unset(r->headers_out, "Allow"); - apr_table_unset(r->headers_out, "Content-Encoding"); - apr_table_unset(r->headers_out, "Content-Language"); - apr_table_unset(r->headers_out, "Content-Length"); - apr_table_unset(r->headers_out, "Content-MD5"); - apr_table_unset(r->headers_out, "Content-Range"); - apr_table_unset(r->headers_out, "Content-Type"); - apr_table_unset(r->headers_out, "Last-Modified"); + for (eh = MOD_CACHE_ENTITY_HEADERS; *eh; ++eh) { + apr_table_unset(r->headers_out, *eh); + } } /* Hold the phone. Some servers might allow us to cache a 2xx, but @@ -1441,10 +1452,14 @@ static apr_status_t cache_save_filter(ap * the cached headers. * * However, before doing that, we need to first merge in - * err_headers_out and we also need to strip any hop-by-hop - * headers that might have snuck in. - */ - r->headers_out = ap_cache_cacheable_headers_out(r); + * err_headers_out (note that store_headers() below already selects + * the cacheable only headers using ap_cache_cacheable_headers_out(), + * here we want to keep the original headers in r->headers_out and + * forward all of them to the client, including non-cacheable ones). + */ + r->headers_out = apr_table_overlay(r->pool, r->headers_out, + r->err_headers_out); + apr_table_clear(r->err_headers_out); /* Merge in our cached headers. However, keep any updated values. */ /* take output, overlay on top of cached */ @@ -1494,6 +1509,13 @@ static apr_status_t cache_save_filter(ap if (status != OK) { r->status = status; + /* Strip the entity headers merged from the cached headers before + * updating the entry (see cache_accept_headers() above). + */ + for (eh = MOD_CACHE_ENTITY_HEADERS; *eh; ++eh) { + apr_table_unset(r->headers_out, *eh); + } + bkt = apr_bucket_flush_create(bb->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, bkt); }