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 4320810C20 for ; Fri, 11 Apr 2014 02:42:35 +0000 (UTC) Received: (qmail 823 invoked by uid 500); 11 Apr 2014 02:42:32 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 600 invoked by uid 500); 11 Apr 2014 02:42:31 -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 593 invoked by uid 99); 11 Apr 2014 02:42:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2014 02:42:30 +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; Fri, 11 Apr 2014 02:42:28 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 957A7238890D; Fri, 11 Apr 2014 02:42:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1586542 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/mod_deflate.xml modules/filters/mod_deflate.c Date: Fri, 11 Apr 2014 02:42:05 -0000 To: cvs@httpd.apache.org From: covener@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140411024205.957A7238890D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: covener Date: Fri Apr 11 02:42:05 2014 New Revision: 1586542 URL: http://svn.apache.org/r1586542 Log: Attempt to make progress on PR39727/PR45023 blocking migration to 2.4. Provide DeflateAlterETag directive to choose between 2.2 behavior, 2.4 behavior, or dropping ETag from the compressed representation. Preserves 2.4 default which breas 304 responses for compressed content. Modified: httpd/httpd/trunk/CHANGES httpd/httpd/trunk/docs/manual/mod/mod_deflate.xml httpd/httpd/trunk/modules/filters/mod_deflate.c Modified: httpd/httpd/trunk/CHANGES URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1586542&r1=1586541&r2=1586542&view=diff ============================================================================== --- httpd/httpd/trunk/CHANGES [utf-8] (original) +++ httpd/httpd/trunk/CHANGES [utf-8] Fri Apr 11 02:42:05 2014 @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_deflate: Add DeflateAlterETag to control how the ETag + is modified. The 'NoChange' parameter mimics 2.2.x behavior. + PR 45023, PR 39727. [Eric Covener] + *) mod_ssl: fix merging of global and vhost-level settings with the SSLCertificateFile, SSLCertificateKeyFile, and SSLOpenSSLConfCmd directives. PR 56353. [Kaspar Brand] Modified: httpd/httpd/trunk/docs/manual/mod/mod_deflate.xml URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_deflate.xml?rev=1586542&r1=1586541&r2=1586542&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/mod/mod_deflate.xml (original) +++ httpd/httpd/trunk/docs/manual/mod/mod_deflate.xml Fri Apr 11 02:42:05 2014 @@ -298,6 +298,36 @@ CustomLog logs/deflate_log deflate + +DeflateAlterETag +How the outgoing ETag header should be modified during compression +DeflateAlterETag AddSuffix|NoChange|Remove +DeflateAlterETag AddSuffix +server configvirtual host + + + +

The DeflateAlterETag directive specifies + how the ETag hader should be altered when a response is compressed.

+
+
AddSuffix
+

Append the compression method onto the end of the ETag, causing + compressed and uncompressed representatins to have unique ETags. + This has been the default since 2.4.0, but prevents serving + "HTTP Not Modified" (304) responses to conditional requests for + compressed content.

+
NoChange
+

Don't change the ETag on a compressed response. This was the default + prior to 2.4.0, but does not satisfy the HTTP/1.1 property that all + representations of the same resource have unique ETags

+
Remove
+

Remove the ETag header from compressed responses. This prevents + some conditional requests from being possible, but avoids the + shortcomings of the preceding options.

+
+
+
+ Modified: httpd/httpd/trunk/modules/filters/mod_deflate.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_deflate.c?rev=1586542&r1=1586541&r2=1586542&view=diff ============================================================================== --- httpd/httpd/trunk/modules/filters/mod_deflate.c (original) +++ httpd/httpd/trunk/modules/filters/mod_deflate.c Fri Apr 11 02:42:05 2014 @@ -54,6 +54,10 @@ static const char deflateFilterName[] = "DEFLATE"; module AP_MODULE_DECLARE_DATA deflate_module; +#define AP_DEFLATE_ETAG_ADDSUFFIX 0 +#define AP_DEFLATE_ETAG_NOCHANGE 1 +#define AP_DEFLATE_ETAG_REMOVE 2 + typedef struct deflate_filter_config_t { int windowSize; @@ -63,6 +67,7 @@ typedef struct deflate_filter_config_t char *note_ratio_name; char *note_input_name; char *note_output_name; + int etag_opt; } deflate_filter_config; /* RFC 1952 Section 2.3 defines the gzip header: @@ -280,6 +285,29 @@ static const char *deflate_set_memlevel( return NULL; } +static const char *deflate_set_etag(cmd_parms *cmd, void *dummy, + const char *arg) +{ + deflate_filter_config *c = ap_get_module_config(cmd->server->module_config, + &deflate_module); + + if (!strcasecmp(arg, "NoChange")) { + c->etag_opt = AP_DEFLATE_ETAG_NOCHANGE; + } + else if (!strcasecmp(arg, "AddSuffix")) { + c->etag_opt = AP_DEFLATE_ETAG_ADDSUFFIX; + } + else if (!strcasecmp(arg, "Remove")) { + c->etag_opt = AP_DEFLATE_ETAG_REMOVE; + } + else { + return "DeflateAlterETAG accepts only 'NoChange', 'AddSuffix', and 'Remove'"; + } + + return NULL; +} + + static const char *deflate_set_compressionlevel(cmd_parms *cmd, void *dummy, const char *arg) { @@ -398,11 +426,16 @@ static apr_status_t deflate_ctx_cleanup( * value inside the double-quotes if an ETag has already been set * and its value already contains double-quotes. PR 39727 */ -static void deflate_check_etag(request_rec *r, const char *transform) +static void deflate_check_etag(request_rec *r, const char *transform, int etag_opt) { const char *etag = apr_table_get(r->headers_out, "ETag"); apr_size_t etaglen; + if (etag_opt == AP_DEFLATE_ETAG_REMOVE) { + apr_table_unset(r->headers_out, "ETag"); + return; + } + if ((etag && ((etaglen = strlen(etag)) > 2))) { if (etag[etaglen - 1] == '"') { apr_size_t transformlen = strlen(transform); @@ -708,7 +741,9 @@ static apr_status_t deflate_out_filter(a } apr_table_unset(r->headers_out, "Content-Length"); apr_table_unset(r->headers_out, "Content-MD5"); - deflate_check_etag(r, "gzip"); + if (c->etag_opt != AP_DEFLATE_ETAG_NOCHANGE) { + deflate_check_etag(r, "gzip", c->etag_opt); + } /* For a 304 response, only change the headers */ if (r->status == HTTP_NOT_MODIFIED) { @@ -1401,7 +1436,9 @@ static apr_status_t inflate_out_filter(a */ apr_table_unset(r->headers_out, "Content-Length"); apr_table_unset(r->headers_out, "Content-MD5"); - deflate_check_etag(r, "gunzip"); + if (c->etag_opt != AP_DEFLATE_ETAG_NOCHANGE) { + deflate_check_etag(r, "gunzip", c->etag_opt); + } /* For a 304 response, only change the headers */ if (r->status == HTTP_NOT_MODIFIED) { @@ -1741,6 +1778,9 @@ static const command_rec deflate_filter_ "Set the Deflate Memory Level (1-9)"), AP_INIT_TAKE1("DeflateCompressionLevel", deflate_set_compressionlevel, NULL, RSRC_CONF, "Set the Deflate Compression Level (1-9)"), + AP_INIT_TAKE1("DeflateAlterEtag", deflate_set_etag, NULL, RSRC_CONF, + "Set how mod_deflate should modify ETAG response headers: 'AddSuffix' (default), 'NoChange' (2.2.x behavior), 'Remove'"), + {NULL} };