Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7354
Modified Files:
mod_xhtml_neg.c
Log Message:
Initial work to handle ETags correctly for negotiated content.
Index: mod_xhtml_neg.c
===================================================================
RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** mod_xhtml_neg.c 8 Mar 2004 20:52:20 -0000 1.6
--- mod_xhtml_neg.c 9 Mar 2004 10:20:27 -0000 1.7
***************
*** 79,83 ****
* 0.7 Added profile handling, fixed up default charset for text/xml
* 0.8 First public release.
! * 0.81 Clean up todos and add some more. Look at ETag issue.
*
* Todo:
--- 79,83 ----
* 0.7 Added profile handling, fixed up default charset for text/xml
* 0.8 First public release.
! * 0.82 Development of ETag handling.
*
* Todo:
***************
*** 158,161 ****
--- 158,174 ----
/*
+ * Record of incoming and outgoing ETag information. For content-negotiated
+ * responses, we add a prefix to outgoing ETag headers, so that each
+ * distinct content-type is given a unique ETag. On conditional GET
+ * requests, we need to strip out the prefix we added earlier, so that the
+ * core Apache code will correctly return 304 responses, etc.
+ */
+
+ typedef struct {
+ char *etag; /* The incoming ETag */
+ int weak; /* Whether the validator is weak or strong */
+ } etag_rec;
+
+ /*
* Record the maps a file extension to zero or more content-types. The content
* types themselves are stored as an array of accept_rec records.
***************
*** 931,935 ****
/*
! * The actual work of this module goes here...
*/
--- 944,948 ----
/*
! * The actual content-negotiation phase of this module goes here...
*/
***************
*** 951,955 ****
if (conf == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
! "internal error: mod_xhtml_neg.c");
return SERVER_ERROR;
};
--- 964,968 ----
if (conf == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
! "internal error -- no configuration: mod_xhtml_neg.c");
return SERVER_ERROR;
};
***************
*** 1064,1067 ****
--- 1077,1150 ----
}
+ /*
+ * This phase fixes up any incoming ETag headers so that conditional
+ * GET requests work correctly for content-negotiated requests.
+ */
+
+ int xhtml_fixup_etags(request_rec *r)
+ {
+ const char *if_match, *if_none_match, *if_range;
+ char *logmessage;
+ xhtml_dir_config *conf;
+ xhtml_neg_state *xns;
+ table *hdrs;
+
+ conf = (xhtml_dir_config *) ap_get_module_config(
+ r->per_dir_config, &xhtml_neg_module);
+
+ xns = ap_get_module_config (r->server->module_config, &xhtml_neg_module);
+
+ if (conf == NULL) {
+ ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
+ "internal error -- no configuration: mod_xhtml_neg.c");
+ return SERVER_ERROR;
+ };
+
+ /* Return OK if either active isn't ON, or stars_ignore is 0. */
+ if( conf->active != ACTIVE_ON ) {
+ return OK;
+ }
+
+ if( conf->stars_ignore == 0 ) {
+ return OK;
+ }
+
+ /* This handler is concerned with rewriting ETag headers.
+ * For HTTP 0.9, this is definitely not relevant.
+ */
+ if( r->assbackwards ) {
+ return OK;
+ }
+
+ /* Retrieve the HTTP request headers table. */
+ hdrs = r->headers_in;
+ if( hdrs == NULL ) {
+ return OK;
+ }
+
+ /* Look for If-Match, If-None-Match, or If-Range */
+ if_match = ap_table_get(hdrs, "If-Match");
+ if_none_match = ap_table_get(hdrs, "If-None-Match");
+ if_range = ap_table_get(hdrs, "If-Range");
+
+ /* Log the results to the log file. */
+ if( xns->log_fd > 0 ) {
+ if( if_match != NULL || if_none_match != NULL || if_range != NULL ) {
+ logmessage = ap_pstrcat(r->pool,
+ "If-Match is: ",
+ (if_match ? if_match : ""), "\n",
+ "If-None-Match is: ",
+ (if_none_match ? if_none_match : ""), "\n",
+ "If-Range is: ",
+ (if_range ? if_range : ""), "\n",
+ NULL);
+
+ write(xns->log_fd, logmessage, mod_xhtml_strlen( logmessage ));
+ }
+ }
+
+ return OK;
+ }
+
/* All Apache configuration file code goes here... */
***************
*** 1278,1282 ****
xhtml_negotiate, /* fixups */
NULL, /* logger */
! NULL, /* header parser */
NULL, /* child_init */
NULL, /* child_exit */
--- 1361,1365 ----
xhtml_negotiate, /* fixups */
NULL, /* logger */
! xhtml_fixup_etags, /* header parser */
NULL, /* child_init */
NULL, /* child_exit */
|