From: Graham Leggett
Date: Sat, 27 Feb 2010 18:35:18 +0000 (+0000)
Subject: Backport:
X-Git-Tag: 2.2.15~51
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3464be8c76cbf0087f5f8f07e5c2c3627f243f7f;p=thirdparty%2Fapache%2Fhttpd.git
Backport:
mod_include: Allow fine control over the removal of Last-Modified and ETag
headers within the INCLUDES filter, making it possible to cache responses if
desired. Fix the default value of the SSIAccessEnable directive.
+1: minfrin, jim, rpluem
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@917008 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/CHANGES b/CHANGES
index 0d364e6c899..572a21f1693 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,11 @@ Changes with Apache 2.2.15
access control is still vulnerable, unless using OpenSSL >= 0.9.8l.
[Joe Orton, Ruediger Pluem, Hartmut Keil ]
+ *) Allow fine control over the removal of Last-Modified and ETag headers
+ within the INCLUDES filter, making it possible to cache responses if
+ desired. Fix the default value of the SSIAccessEnable directive.
+ [Graham Leggett]
+
*) core: Fix potential memory leaks by making sure to not destroy
bucket brigades that have been created by earlier filters.
[Stefan Fritsch]
diff --git a/STATUS b/STATUS
index 937de7a9f6d..5e26154f261 100644
--- a/STATUS
+++ b/STATUS
@@ -87,13 +87,6 @@ RELEASE SHOWSTOPPERS:
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- * mod_include: Allow fine control over the removal of Last-Modified and ETag headers
- within the INCLUDES filter, making it possible to cache responses if
- desired. Fix the default value of the SSIAccessEnable directive.
- 2.2.x patch: http://people.apache.org/~minfrin/mod_include_caching2-2.2.patch
- Trunk patch: http://svn.apache.org/viewvc?rev=905406&view=rev
- +1: minfrin, jim, rpluem
-
* mod_log_config: Add the R option to log the handler used within the
request.
Submitted by: Christian Folini
diff --git a/docs/manual/mod/mod_include.xml b/docs/manual/mod/mod_include.xml
index 4c7d64e70d3..f2a717c4a30 100644
--- a/docs/manual/mod/mod_include.xml
+++ b/docs/manual/mod/mod_include.xml
@@ -800,6 +800,84 @@ displayed
+
+SSIETag
+Controls whether ETags are generated by the server.
+SSIETag on|off
+SSIETag off
+directory.htaccess
+
+
+ Under normal circumstances, a file filtered by mod_include
+ may contain elements that are either dynamically generated, or that may
+ have changed independently of the original file. As a result, by default
+ the server is asked not to generate an ETag
header for the
+ response by adding no-etag
to the request notes.
+
+ The SSIETag directive suppresses this
+ behaviour, and allows the server to generate an ETag
header.
+ This can be used to enable caching of the output. Note that a backend server
+ or dynamic content generator may generate an ETag of its own, ignoring
+ no-etag
, and this ETag will be passed by
+ mod_include regardless of the value of this setting.
+ SSIETag can take on the following values:
+
+
+
+ off
+ no-etag
will be added to the request notes, and the server
+ is asked not to generate an ETag. Where a server ignores the value of
+ no-etag
and generates an ETag anyway, the ETag will be
+ respected.
+
+ on
+ - Existing ETags will be respected, and ETags generated by the server will
+ be passed on in the response.
+
+
+
+
+
+
+
+SSILastModified
+Controls whether Last-Modified
headers are generated by the
+server.
+SSILastModified on|off
+SSILastModified off
+directory.htaccess
+
+
+ Under normal circumstances, a file filtered by mod_include
+ may contain elements that are either dynamically generated, or that may
+ have changed independently of the original file. As a result, by default
+ the Last-Modified
header is stripped from the response.
+
+ The SSILastModified directive overrides this
+ behaviour, and allows the Last-Modified
header to be respected
+ if already present, or set if the header is not already present. This can
+ be used to enable caching of the output. SSILastModified
+ can take on the following values:
+
+
+
+ off
+ - The
Last-Modified
header will be stripped from responses,
+ unless the XBitHack directive
+ is set to full
as described below.
+
+ on
+ - The
Last-Modified
header will be respected if already
+ present in a response, and added to the response if the response is a
+ file and the header is missing. The
+ SSILastModified directive
+ takes precedence over XBitHack.
+
+
+
+
+
+
XBitHack
Parse SSI directives in files with the execute bit
@@ -837,7 +915,14 @@ set
group-execute bit is unset for every SSI script which might #include
a CGI or otherwise produces different output on
each hit (or could potentially change on subsequent requests).
+
+ The SSILastModified
+ directive takes precedence over the
+ XBitHack directive when
+ SSILastModified is set to
+ on
.
+
diff --git a/modules/filters/mod_include.c b/modules/filters/mod_include.c
index 6ec0fa8950c..59ce8e3ef7a 100644
--- a/modules/filters/mod_include.c
+++ b/modules/filters/mod_include.c
@@ -115,7 +115,9 @@ typedef struct {
const char *default_time_fmt;
const char *undefined_echo;
xbithack_t xbithack;
- const int accessenable;
+ int accessenable;
+ int lastmodified;
+ int etag;
} include_dir_config;
typedef struct {
@@ -461,6 +463,9 @@ static const char lazy_eval_sentinel;
#define DEFAULT_ERROR_MSG "[an error occurred while processing this directive]"
#define DEFAULT_TIME_FORMAT "%A, %d-%b-%Y %H:%M:%S %Z"
#define DEFAULT_UNDEFINED_ECHO "(none)"
+#define DEFAULT_ACCESSENABLE 0
+#define DEFAULT_LASTMODIFIED 0
+#define DEFAULT_ETAG 0
#ifdef XBITHACK
#define DEFAULT_XBITHACK XBITHACK_FULL
@@ -3529,7 +3534,9 @@ static int includes_setup(ap_filter_t *f)
* We don't know if we are going to be including a file or executing
* a program - in either case a strong ETag header will likely be invalid.
*/
- apr_table_setn(f->r->notes, "no-etag", "");
+ if (!conf->etag) {
+ apr_table_setn(f->r->notes, "no-etag", "");
+ }
return OK;
}
@@ -3618,13 +3625,32 @@ static apr_status_t includes_filter(ap_filter_t *f, apr_bucket_brigade *b)
* a program which may change the Last-Modified header or make the
* content completely dynamic. Therefore, we can't support these
* headers.
- * Exception: XBitHack full means we *should* set the Last-Modified field.
+ *
+ * Exception: XBitHack full means we *should* set the
+ * Last-Modified field.
+ *
+ * SSILastModified on means we *should* set the Last-Modified field
+ * if not present, or respect an existing value if present.
*/
+ /* Must we respect the last modified header? By default, no */
+ if (conf->lastmodified) {
+
+ /* update the last modified if we have a valid time, and only if
+ * we don't already have a valid last modified.
+ */
+ if (r->finfo.valid & APR_FINFO_MTIME
+ && !apr_table_get(f->r->headers_out, "Last-Modified")) {
+ ap_update_mtime(r, r->finfo.mtime);
+ ap_set_last_modified(r);
+ }
+
+ }
+
/* Assure the platform supports Group protections */
- if ((conf->xbithack == XBITHACK_FULL)
+ else if (((conf->xbithack == XBITHACK_FULL)
&& (r->finfo.valid & APR_FINFO_GPROT)
- && (r->finfo.protection & APR_GEXECUTE)) {
+ && (r->finfo.protection & APR_GEXECUTE))) {
ap_update_mtime(r, r->finfo.mtime);
ap_set_last_modified(r);
}
@@ -3704,6 +3730,9 @@ static void *create_includes_dir_config(apr_pool_t *p, char *dummy)
result->default_time_fmt = DEFAULT_TIME_FORMAT;
result->undefined_echo = DEFAULT_UNDEFINED_ECHO;
result->xbithack = DEFAULT_XBITHACK;
+ result->accessenable = DEFAULT_ACCESSENABLE;
+ result->lastmodified = DEFAULT_LASTMODIFIED;
+ result->etag = DEFAULT_ETAG;
return result;
}
@@ -3856,6 +3885,14 @@ static const command_rec includes_cmds[] =
AP_INIT_FLAG("SSIAccessEnable", ap_set_flag_slot,
(void *)APR_OFFSETOF(include_dir_config, accessenable),
OR_LIMIT, "Whether testing access is enabled. Limited to 'on' or 'off'"),
+ AP_INIT_FLAG("SSILastModified", ap_set_flag_slot,
+ (void *)APR_OFFSETOF(include_dir_config, lastmodified),
+ OR_LIMIT, "Whether to set the last modified header or respect "
+ "an existing header. Limited to 'on' or 'off'"),
+ AP_INIT_FLAG("SSIEtag", ap_set_flag_slot,
+ (void *)APR_OFFSETOF(include_dir_config, etag),
+ OR_LIMIT, "Whether to allow the generation of ETags within the server. "
+ "Existing ETags will be preserved. Limited to 'on' or 'off'"),
{NULL}
};