Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13873
Modified Files:
mod_xhtml_neg.c
Log Message:
Make sure vlist_validator entries are merged correctly.
Index: mod_xhtml_neg.c
===================================================================
RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** mod_xhtml_neg.c 11 Mar 2004 12:22:39 -0000 1.10
--- mod_xhtml_neg.c 11 Mar 2004 12:59:49 -0000 1.11
***************
*** 461,464 ****
--- 461,466 ----
* Construct an Etag suffix to be appended to the standard Apache
* ETag.
+ *
+ * Todo: could probably macro-ise this function.
*/
***************
*** 469,472 ****
--- 471,524 ----
/*
+ * Merge vlist_validators from different modules. This code is modified
+ * from code in http_protocol.c in the Apache 1.3 core.
+ */
+
+ static char *merge_validators(pool *p, char *old_variant, char *new_variant)
+ {
+ char *etag;
+ int old_weak, new_weak;
+
+ if (mod_xhtml_strempty(old_variant)) {
+ etag = new_variant;
+ } else if (mod_xhtml_strempty(new_variant)) {
+ etag = old_variant;
+ } else {
+ /* Merge any two vlist entries: one from any previous module, and
+ * one from the current module. This merging makes revalidation
+ * somewhat safer, ensures that caches which can deal with
+ * Vary will (eventually) be updated if the set of variants is
+ * changed, and is also a protocol requirement for transparent
+ * content negotiation.
+ */
+
+ /* if the variant list validator is weak, we make the whole
+ * structured etag weak. If we would not, then clients could
+ * have problems merging range responses if we have different
+ * variants with the same non-globally-unique strong etag.
+ */
+
+ old_weak = (old_variant[0] == 'W');
+ new_weak = (new_variant[0] == 'W');
+
+ /* merge old and new variant_etags into a structured etag */
+ old_variant[strlen(old_variant) - 1] = '\0';
+ if (new_weak)
+ new_variant += 3;
+ else
+ new_variant++;
+
+ if((old_weak == 0) && (new_weak != 0)) {
+ etag = ap_pstrcat(p, "W/", old_variant, ";", new_variant, NULL);
+ } else {
+ etag = ap_pstrcat(p, old_variant, ";", new_variant, NULL);
+ }
+ }
+
+ return etag;
+ }
+
+
+ /*
* For a given filename, scan through an array of extension_rec records
* until we find a match. The first match wins. If no match is found,
***************
*** 1059,1063 ****
*/
char *new_etag = construct_etag_suffix( r->pool, *result_index );
! r->vlist_validator = new_etag;
r->content_type = result_type;
--- 1111,1116 ----
*/
char *new_etag = construct_etag_suffix( r->pool, *result_index );
! r->vlist_validator = merge_validators( r->pool, r->vlist_validator,
! new_etag );
r->content_type = result_type;
|