mod-xhtml-neg-cvs Mailing List for XHTML negotiation module (Page 4)
Brought to you by:
run2000
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(51) |
Apr
(37) |
May
|
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(3) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ru...@us...> - 2004-03-13 09:36:00
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7825 Modified Files: mod_xhtml_neg.c Log Message: Fixed up Etag handling for 2.0 filters. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mod_xhtml_neg.c 13 Mar 2004 08:10:31 -0000 1.2 --- mod_xhtml_neg.c 13 Mar 2004 09:27:13 -0000 1.3 *************** *** 522,567 **** */ ! static char *merge_validators(apr_pool_t *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 = apr_pstrcat(p, "W/", old_variant, ";", new_variant, NULL); ! } else { ! etag = apr_pstrcat(p, old_variant, ";", new_variant, NULL); ! } } ! return etag; } --- 522,567 ---- */ ! static const char *merge_validators(apr_pool_t *p, const char *old_variant, ! const char *new_variant) { int old_weak, new_weak; + char *old_variable; if (mod_xhtml_strempty(old_variant)) { ! return new_variant; } else if (mod_xhtml_strempty(new_variant)) { ! return old_variant; ! } ! /* 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_variable = apr_pstrdup( p, old_variant ); ! old_variable[strlen(old_variable) - 1] = '\0'; ! if ((new_weak) && (mod_xhtml_strlen(old_variable) > 3)) ! new_variant += 3; ! else ! new_variant++; ! ! if((old_weak == 0) && (new_weak != 0)) { ! return apr_pstrcat(p, "W/", old_variable, ";", new_variant, NULL); } ! return apr_pstrcat(p, old_variable, ";", new_variant, NULL); } *************** *** 1070,1082 **** }; - /* 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; - } - /* Only service requests for GET or HEAD methods. */ if( r->method_number != M_GET ) { --- 1070,1073 ---- *************** *** 1084,1094 **** } - /* This module is concerned with rewriting Content-Type, and adding a Vary - * header. For HTTP 0.9, neither of these functions are relevant. - */ - if( r->assbackwards ) { - return OK; - } - /* Retrieve the HTTP request headers table. */ hdrs = r->headers_in; --- 1075,1078 ---- *************** *** 1119,1122 **** --- 1103,1107 ---- /* Do some logging... */ if( xns->log_fd != NULL ) { + logmessage = apr_pstrcat(r->pool, "Filename is ", filename, "\n", *************** *** 1153,1162 **** if( result_rec != NULL ) { ! /* Construct a "suffix" for the ETag, and make sure it gets * appended to the ETag that would normally be returned * by Apache. */ ! r->vlist_validator = merge_validators( r->pool, r->vlist_validator, ! result_rec->hashcode ); r->content_type = reconstruct_content_type( r->pool, result_rec ); --- 1138,1149 ---- if( result_rec != NULL ) { ! /* Construct a new ETag suffix, and make sure it gets * appended to the ETag that would normally be returned * by Apache. */ ! const char *old_etag = apr_table_get( r->headers_out, "Etag" ); ! const char *etag = merge_validators( r->pool, old_etag, ! result_rec->hashcode ); ! apr_table_setn(r->headers_out, "Etag", etag ); r->content_type = reconstruct_content_type( r->pool, result_rec ); *************** *** 1164,1168 **** logmessage = apr_pstrcat(r->pool, "Best content-type: ", r->content_type, "\n", ! "New validator is: ", r->vlist_validator, "\n", NULL ); logsize = mod_xhtml_strlen( logmessage ); --- 1151,1155 ---- logmessage = apr_pstrcat(r->pool, "Best content-type: ", r->content_type, "\n", ! "New validator is: ", etag, "\n", NULL ); logsize = mod_xhtml_strlen( logmessage ); *************** *** 1193,1196 **** --- 1180,1219 ---- } + /* Filter code goes here */ + static void xhtml_neg_insert_output_filter(request_rec *r) + { + xhtml_dir_config *conf = ap_get_module_config(r->per_dir_config, + &xhtml_neg_module); + + if ((conf->active == ACTIVE_ON) && (conf->stars_ignore > 0)) { + ap_add_output_filter("XHTML_NEGOTIATION_OUT", NULL, r, r->connection); + } + } + + /* + * This is the output filter identified by the name "XHTML_NEGOTIATION_OUT" + */ + + static apr_status_t xhtml_negotiation_output_filter(ap_filter_t *f, + apr_bucket_brigade *in) + { + xhtml_dir_config *conf = ap_get_module_config(f->r->per_dir_config, + &xhtml_neg_module); + + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, f->r->server, + "mod_xhtml_neg: xhtml_negotiation_output_filter()"); + + /* do the fixup */ + xhtml_negotiate(f->r); + + /* remove ourselves from the filter chain */ + ap_remove_output_filter(f); + + /* send the data up the stack */ + return ap_pass_brigade(f->next,in); + } + + + /* All Apache configuration file code goes here... */ *************** *** 1427,1431 **** { ap_hook_post_config(init_xhtml_log, NULL, NULL, APR_HOOK_MIDDLE); ! ap_hook_fixups(xhtml_negotiate, NULL, NULL, APR_HOOK_MIDDLE); } --- 1450,1457 ---- { ap_hook_post_config(init_xhtml_log, NULL, NULL, APR_HOOK_MIDDLE); ! ap_hook_insert_filter(xhtml_neg_insert_output_filter, NULL, NULL, APR_HOOK_LAST); ! ap_register_output_filter("XHTML_NEGOTIATION_OUT", ! xhtml_negotiation_output_filter, ! NULL, AP_FTYPE_CONTENT_SET); } |
From: <ru...@us...> - 2004-03-13 08:19:17
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29307 Modified Files: mod_xhtml_neg.c Log Message: Fixed some stupid mistakes surrounding configuration. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** mod_xhtml_neg.c 13 Mar 2004 07:07:50 -0000 1.1.1.1 --- mod_xhtml_neg.c 13 Mar 2004 08:10:31 -0000 1.2 *************** *** 112,122 **** #include "http_log.h" ! static int xfer_flags = (O_WRONLY | O_APPEND | O_CREAT); ! #if defined(OS2) || defined(WIN32) || defined(NETWARE) ! /* OS/2 dosen't support users and groups */ ! static mode_t xfer_mode = (S_IREAD | S_IWRITE); ! #else ! static mode_t xfer_mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); ! #endif /* #define MOD_XHTML_NEG_DEBUG 1 */ --- 112,117 ---- #include "http_log.h" ! static int xfer_flags = (APR_WRITE | APR_APPEND | APR_CREATE); ! static apr_fileperms_t xfer_perms = APR_OS_DEFAULT; /* #define MOD_XHTML_NEG_DEBUG 1 */ *************** *** 142,146 **** typedef struct { int active; /* Is the module active for this directory? */ ! apr_array_header_t *extensions; /* An array of extension_rec records */ int stars_ignore; /* How many content-type stars before we ignore */ --- 137,141 ---- typedef struct { int active; /* Is the module active for this directory? */ ! apr_array_header_t *extensions; /* An array of extension_rec records */ int stars_ignore; /* How many content-type stars before we ignore */ *************** *** 167,171 **** typedef struct { ! char *extension; /* Filename extension */ apr_array_header_t *content_types; /* Array of content accept headers */ } extension_rec; --- 162,166 ---- typedef struct { ! char *extension; /* Filename extension */ apr_array_header_t *content_types; /* Array of content accept headers */ } extension_rec; *************** *** 1208,1212 **** void *in_dir_config, int arg) { ! xhtml_dir_config *dir_config = (xhtml_dir_config *)dir_config; /* If we're here at all it's because someone explicitly --- 1203,1207 ---- void *in_dir_config, int arg) { ! xhtml_dir_config *dir_config = in_dir_config; /* If we're here at all it's because someone explicitly *************** *** 1250,1254 **** extension_rec *rec; accept_rec *new; ! xhtml_dir_config *dir_config = (xhtml_dir_config *)in_dir_config; char *content_type = apr_pstrdup( cmd->pool, type ); --- 1245,1249 ---- extension_rec *rec; accept_rec *new; ! xhtml_dir_config *dir_config = in_dir_config; char *content_type = apr_pstrdup( cmd->pool, type ); *************** *** 1339,1342 **** --- 1334,1338 ---- static void *create_xhtml_dir_config(apr_pool_t *p, char *dummy) { + xhtml_dir_config *new = (xhtml_dir_config *) apr_pcalloc(p, sizeof(xhtml_dir_config)); *************** *** 1416,1420 **** fd = NULL; ! if( apr_file_open(&fd, fname, xfer_flags, xfer_mode, pconf) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "could not open log file %s.", fname); --- 1412,1416 ---- fd = NULL; ! if( apr_file_open(&fd, fname, xfer_flags, xfer_perms, pconf) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "could not open log file %s.", fname); |
From: <ru...@us...> - 2004-03-13 07:19:00
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/.libs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21543 Removed Files: mod_xhtml_neg.lai Log Message: Remove hidden files from import. --- mod_xhtml_neg.lai DELETED --- |
From: <ru...@us...> - 2004-03-13 01:44:08
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6540 Modified Files: mod_xhtml_neg.c Log Message: Profile isn't included as part of the hashcode generation sequence, since it isn't returned in the Content-Type header. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** mod_xhtml_neg.c 12 Mar 2004 10:18:09 -0000 1.19 --- mod_xhtml_neg.c 13 Mar 2004 01:35:26 -0000 1.20 *************** *** 485,490 **** * two hyphen separated, zero padded hexadecimal numbers. * ! * The data that we use to generate the hash is the content-type, charset, ! * and profile, concatenated as one long string. */ --- 485,494 ---- * two hyphen separated, zero padded hexadecimal numbers. * ! * The data that we use to generate the hash is the content-type and charset, ! * concatenated as one long string. ! * ! * Todo: ! * If the content-type returned ever includes the "profile" parameter, ! * include it as part of the hash code. */ *************** *** 495,499 **** int len, i; ! data = ap_pstrcat( p, rec->name, rec->charset, rec->profile, NULL ); len = mod_xhtml_strlen( data ); hash = 7; --- 499,503 ---- int len, i; ! data = ap_pstrcat( p, rec->name, rec->charset, NULL ); len = mod_xhtml_strlen( data ); hash = 7; |
From: <ru...@us...> - 2004-03-12 10:45:29
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9684 Modified Files: mod_xhtml_neg.c Log Message: More comment fixes for the hashcode function. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** mod_xhtml_neg.c 12 Mar 2004 10:16:32 -0000 1.18 --- mod_xhtml_neg.c 12 Mar 2004 10:18:09 -0000 1.19 *************** *** 483,489 **** * consists of two simple values, the length of the interesting data, * and a simple hash of each character. These are then represented as ! * two hyphen separated hexadecimal numbers. * ! * The data that we generate the hash from is the content-type, charset, * and profile, concatenated as one long string. */ --- 483,489 ---- * consists of two simple values, the length of the interesting data, * and a simple hash of each character. These are then represented as ! * two hyphen separated, zero padded hexadecimal numbers. * ! * The data that we use to generate the hash is the content-type, charset, * and profile, concatenated as one long string. */ |
From: <ru...@us...> - 2004-03-12 10:43:52
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9206 Modified Files: mod_xhtml_neg.c Log Message: Minor function name change, remove old Etag generation code, minor comment fixes. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** mod_xhtml_neg.c 12 Mar 2004 10:05:59 -0000 1.17 --- mod_xhtml_neg.c 12 Mar 2004 10:16:32 -0000 1.18 *************** *** 2,6 **** * The Apache Software License, Version 1.1 * ! * Copyright (c) 2000-2002 The Apache Software Foundation. All rights * reserved. * --- 2,6 ---- * The Apache Software License, Version 1.1 * ! * Copyright (c) 2000-2004 The Apache Software Foundation. All rights * reserved. * *************** *** 85,89 **** * 0.9 ETag handled correctly for different content types. * - * * Directives: * --- 85,88 ---- *************** *** 480,495 **** /* - * Construct an Etag suffix to be appended to the standard Apache - * ETag. - * - * Todo: could probably macro-ise this function. - */ - - static char *construct_etag_suffix( pool *p, int index ) - { - return ap_psprintf( p, "\"mxn-%d\"", index ); - } - - /* * Make a simple hash code for the given accept_rec structure. This allows * us to generate unique Etags for accepted content-types. The Etag --- 479,482 ---- *************** *** 502,506 **** */ ! static void make_hashcode( pool *p, accept_rec *rec ) { char *data; --- 489,493 ---- */ ! static void make_etag_hashcode( pool *p, accept_rec *rec ) { char *data; *************** *** 1263,1267 **** new = (accept_rec *) ap_push_array( rec->content_types ); get_entry( cmd->pool, new, contenttype ); ! make_hashcode( cmd->pool, new ); return NULL; --- 1250,1254 ---- new = (accept_rec *) ap_push_array( rec->content_types ); get_entry( cmd->pool, new, contenttype ); ! make_etag_hashcode( cmd->pool, new ); return NULL; |
From: <ru...@us...> - 2004-03-12 10:33:19
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7025 Modified Files: mod_xhtml_neg.c Log Message: Always pad out hash code to 8 digits. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** mod_xhtml_neg.c 12 Mar 2004 09:51:22 -0000 1.16 --- mod_xhtml_neg.c 12 Mar 2004 10:05:59 -0000 1.17 *************** *** 519,523 **** } ! rec->hashcode = ap_psprintf(p, "\"%02x-%lx\"", len, (unsigned long) hash); } --- 519,523 ---- } ! rec->hashcode = ap_psprintf(p, "\"%02x-%08lx\"", len, (unsigned long) hash); } |
From: <ru...@us...> - 2004-03-12 10:18:44
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4611 Modified Files: mod_xhtml_neg.c Log Message: More comments added about the hashcode algorithm. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** mod_xhtml_neg.c 12 Mar 2004 09:48:31 -0000 1.15 --- mod_xhtml_neg.c 12 Mar 2004 09:51:22 -0000 1.16 *************** *** 497,500 **** --- 497,503 ---- * and a simple hash of each character. These are then represented as * two hyphen separated hexadecimal numbers. + * + * The data that we generate the hash from is the content-type, charset, + * and profile, concatenated as one long string. */ *************** *** 509,512 **** --- 512,518 ---- hash = 7; + /* Note that we use a multiplier of 128 rather than 256 since HTTP + * headers are only guaranteed 7-bit US-ASCII safe. + */ for( i = 0; i < len; i++ ) { hash = hash * 128 + data[ i ]; |
From: <ru...@us...> - 2004-03-12 10:15:52
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4162 Modified Files: mod_xhtml_neg.c Log Message: Function comments added. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** mod_xhtml_neg.c 12 Mar 2004 09:32:59 -0000 1.14 --- mod_xhtml_neg.c 12 Mar 2004 09:48:31 -0000 1.15 *************** *** 167,170 **** --- 167,175 ---- /* + * Utility functions for strings, since we can't rely on these functions being + * included. + */ + + /* * Test whether a string is empty without having to do a full scan of the * string just to return a length, as per strlen. *************** *** 197,202 **** /* ! * Utility functions for strings, since we can't rely on these functions being ! * included. */ --- 202,206 ---- /* ! * Compare one string against another in a case-sensitive manner. */ *************** *** 231,234 **** --- 235,242 ---- } + /* + * Compare one string against another in a case-insensitive manner. + */ + static int mod_xhtml_stricmp( const char *str1, const char *str2 ) { int offset = 0; *************** *** 270,273 **** --- 278,286 ---- } + /* + * Compare strings up to a specified limit in a case-sensitive manner. + * If a NULL byte is encountered, finish comparing at that character. + */ + static int mod_xhtml_strncmp( const char *str1, const char *str2, const int len ) { *************** *** 302,305 **** --- 315,323 ---- } + /* + * Compare strings up to a specified limit in a case-insensitive manner. + * If a NULL byte is encountered, finish comparing at that character. + */ + static int mod_xhtml_strnicmp( const char *str1, const char *str2, const int len ) { *************** *** 344,347 **** --- 362,370 ---- } + /* + * Determines if the given string end with the given suffix. Case matching + * can be enabled or disabled. + */ + static int mod_xhtml_strendswith( const char *reference, const char *suffix, const int casecompare ) { *************** *** 1121,1125 **** accept_charsets = do_accept_charset_line(r->pool, accept_charset); ! /* Allocate storage for index of result, used in Etag. */ result_rec = best_match( accept_types, content_types, accept_charsets, conf->stars_ignore, --- 1144,1148 ---- accept_charsets = do_accept_charset_line(r->pool, accept_charset); ! /* Find accept_rec of best result, if any. */ result_rec = best_match( accept_types, content_types, accept_charsets, conf->stars_ignore, *************** *** 1168,1171 **** --- 1191,1198 ---- /* All Apache configuration file code goes here... */ + /* + * Is this module active for the given directory. + */ + static const char *set_xhtml_active(cmd_parms *cmd, xhtml_dir_config *dir_config, int arg) *************** *** 1182,1185 **** --- 1209,1217 ---- } + /* + * Set whether HTTP 1.0 caching should be allowed. Default to "no" unless + * specifically overridden. + */ + static const char *set_xhtml_cache_negotiated(cmd_parms *cmd, void *dummy, int arg) *************** *** 1197,1200 **** --- 1229,1236 ---- } + /* + * Add content types for the given file extension. + */ + static const char *add_xhtml_type(cmd_parms *cmd, xhtml_dir_config *t, char *ext, char *contenttype) *************** *** 1226,1229 **** --- 1262,1270 ---- } + /* + * Note the minimun number of stars in an Accept token that should be + * ignored when performing negotiation. + */ + static const char *add_xhtml_ignore(cmd_parms *cmd, xhtml_dir_config *t, char *stars) *************** *** 1244,1247 **** --- 1285,1292 ---- } + /* + * Set the log file name for this module. + */ + static const char *add_xhtml_log(cmd_parms *cmd, void *dummy, char *logfile) { *************** *** 1257,1260 **** --- 1302,1309 ---- } + /* + * Create a default XHTML negotiation module configuration record. + */ + static void *make_xhtml_neg_state (pool *p, server_rec *s) { *************** *** 1269,1272 **** --- 1318,1325 ---- } + /* + * Create a default directory configuration module. + */ + static void *create_xhtml_dir_config(pool *p, char *dummy) { *************** *** 1280,1283 **** --- 1333,1340 ---- } + /* + * Merge configuration info from different directories. + */ + static void *merge_xhtml_dir_configs(pool *p, void *basev, void *addv) { *************** *** 1319,1322 **** --- 1376,1383 ---- } + /* + * Initialize the log file, if one is specified. + */ + static void init_xhtml_log (server_rec *s, pool *p) { |
From: <ru...@us...> - 2004-03-12 10:00:18
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1671 Modified Files: mod_xhtml_neg.c Log Message: Create Etags out of a simple hash of the negotiated content. Simplify some code slightly. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** mod_xhtml_neg.c 11 Mar 2004 13:06:04 -0000 1.13 --- mod_xhtml_neg.c 12 Mar 2004 09:32:59 -0000 1.14 *************** *** 151,154 **** --- 151,155 ---- char *profile; /* The XHTML profile, as per RFC 3236 */ int stars; /* How many stars in this accept name? */ + char *hashcode; } accept_rec; *************** *** 468,471 **** --- 469,498 ---- /* + * Make a simple hash code for the given accept_rec structure. This allows + * us to generate unique Etags for accepted content-types. The Etag + * consists of two simple values, the length of the interesting data, + * and a simple hash of each character. These are then represented as + * two hyphen separated hexadecimal numbers. + */ + + static void make_hashcode( pool *p, accept_rec *rec ) + { + char *data; + unsigned long hash; + int len, i; + + data = ap_pstrcat( p, rec->name, rec->charset, rec->profile, NULL ); + len = mod_xhtml_strlen( data ); + hash = 7; + + for( i = 0; i < len; i++ ) { + hash = hash * 128 + data[ i ]; + } + + rec->hashcode = ap_psprintf(p, "\"%02x-%lx\"", + len, (unsigned long) hash); + } + + /* * Merge vlist_validators from different modules. This code is adapted * from code in http_protocol.c in the Apache 1.3 core. *************** *** 553,556 **** --- 580,584 ---- result->profile = ""; result->stars = 0; + result->hashcode = ""; /* *************** *** 711,714 **** --- 739,743 ---- new->profile = ""; new->stars = 0; + new->hashcode = ""; } *************** *** 877,884 **** */ ! static char *best_match(pool *p, array_header *accept_type, array_header *content_type, array_header *accept_charset, ! int stars_to_match, xhtml_neg_state *xns, ! int *result_index) { float best_q = 0.0f; --- 906,912 ---- */ ! static accept_rec *best_match(array_header *accept_type, array_header *content_type, array_header *accept_charset, ! int stars_to_match, xhtml_neg_state *xns) { float best_q = 0.0f; *************** *** 892,898 **** char *logmessage; - /* Set result index to 0 initially. */ - *result_index = 0; - /* Deal with silly null pointers when Accept: header is empty */ if((content_type == NULL) || (accept_type == NULL)) { --- 920,923 ---- *************** *** 950,954 **** best_stars = curr_stars; best_type = curr_content; - *result_index = i + 1; } } --- 975,978 ---- *************** *** 963,967 **** /* Return the reconstructed content-type header. */ ! return reconstruct_content_type( p, best_type ); } --- 987,991 ---- /* Return the reconstructed content-type header. */ ! return best_type; } *************** *** 1002,1006 **** { array_header *extensions, *accept_types, *accept_charsets, *content_types; ! const char *content_accept, *accept_charset, *result_type; char *filename, *extension, *logmessage; xhtml_dir_config *conf; --- 1026,1030 ---- { array_header *extensions, *accept_types, *accept_charsets, *content_types; ! const char *content_accept, *accept_charset; char *filename, *extension, *logmessage; xhtml_dir_config *conf; *************** *** 1008,1012 **** extension_rec *item; table *hdrs; ! int *result_index; conf = (xhtml_dir_config *) ap_get_module_config( --- 1032,1036 ---- extension_rec *item; table *hdrs; ! accept_rec *result_rec; conf = (xhtml_dir_config *) ap_get_module_config( *************** *** 1098,1120 **** /* Allocate storage for index of result, used in Etag. */ ! result_index = (int *) ap_palloc( r->pool, sizeof(int)); ! result_type = best_match( r->pool, accept_types, content_types, ! accept_charsets, conf->stars_ignore, ! xns, result_index ); ! if( result_type != NULL ) { /* Construct a "suffix" for the ETag, and make sure it gets * appended to the ETag that would normally be returned * by Apache. */ - char *new_validator = construct_etag_suffix( r->pool, *result_index ); r->vlist_validator = merge_validators( r->pool, r->vlist_validator, ! new_validator ); ! r->content_type = result_type; if( xns->log_fd > 0 ) { logmessage = ap_pstrcat(r->pool, ! "Best content-type: ", result_type, "\n", ! "New validator is: ", new_validator, "\n", NULL ); write(xns->log_fd, logmessage, mod_xhtml_strlen( logmessage )); --- 1122,1142 ---- /* Allocate storage for index of result, used in Etag. */ ! result_rec = best_match( accept_types, content_types, ! accept_charsets, conf->stars_ignore, ! xns ); ! if( result_rec != NULL ) { /* Construct a "suffix" for the ETag, and make sure it gets * appended to the ETag that would normally be returned * by Apache. */ r->vlist_validator = merge_validators( r->pool, r->vlist_validator, ! result_rec->hashcode ); ! r->content_type = reconstruct_content_type( r->pool, result_rec ); if( xns->log_fd > 0 ) { logmessage = ap_pstrcat(r->pool, ! "Best content-type: ", r->content_type, "\n", ! "New validator is: ", r->vlist_validator, "\n", NULL ); write(xns->log_fd, logmessage, mod_xhtml_strlen( logmessage )); *************** *** 1199,1202 **** --- 1221,1225 ---- new = (accept_rec *) ap_push_array( rec->content_types ); get_entry( cmd->pool, new, contenttype ); + make_hashcode( cmd->pool, new ); return NULL; |
From: <ru...@us...> - 2004-03-11 13:32:47
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15338 Modified Files: mod_xhtml_neg.c Log Message: Some minor comment fixups and column wrapping. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** mod_xhtml_neg.c 11 Mar 2004 13:02:19 -0000 1.12 --- mod_xhtml_neg.c 11 Mar 2004 13:06:04 -0000 1.13 *************** *** 269,273 **** } ! static int mod_xhtml_strncmp( const char *str1, const char *str2, const int len ) { int offset = 0; char ch1, ch2; --- 269,274 ---- } ! static int mod_xhtml_strncmp( const char *str1, const char *str2, ! const int len ) { int offset = 0; char ch1, ch2; *************** *** 467,471 **** /* ! * Merge vlist_validators from different modules. This code is modified * from code in http_protocol.c in the Apache 1.3 core. */ --- 468,472 ---- /* ! * Merge vlist_validators from different modules. This code is adapted * from code in http_protocol.c in the Apache 1.3 core. */ *************** *** 899,903 **** } ! /* Set up default star matching if none is specified in the config file. */ if( stars_to_match < 0 ) { stars_to_match = 2; --- 900,905 ---- } ! /* Set up default star matching if none is specified in the ! config file. */ if( stars_to_match < 0 ) { stars_to_match = 2; *************** *** 1106,1112 **** * by Apache. */ ! 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; --- 1108,1114 ---- * by Apache. */ ! char *new_validator = construct_etag_suffix( r->pool, *result_index ); r->vlist_validator = merge_validators( r->pool, r->vlist_validator, ! new_validator ); r->content_type = result_type; *************** *** 1114,1118 **** logmessage = ap_pstrcat(r->pool, "Best content-type: ", result_type, "\n", ! "New Etag is: ", new_etag, "\n", NULL ); write(xns->log_fd, logmessage, mod_xhtml_strlen( logmessage )); --- 1116,1120 ---- logmessage = ap_pstrcat(r->pool, "Best content-type: ", result_type, "\n", ! "New validator is: ", new_validator, "\n", NULL ); write(xns->log_fd, logmessage, mod_xhtml_strlen( logmessage )); |
From: <ru...@us...> - 2004-03-11 13:28:58
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14498 Modified Files: mod_xhtml_neg.c Log Message: Fixed up header comments relating to Etag headers. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** mod_xhtml_neg.c 11 Mar 2004 12:59:49 -0000 1.11 --- mod_xhtml_neg.c 11 Mar 2004 13:02:19 -0000 1.12 *************** *** 70,73 **** --- 70,77 ---- * Also deals with issues contained in RFC 2854. * + * From http://www.w3.org/2003/01/xhtml-mimetype/content-negotiation + * Etags should be unique for each content-type returned. This is done by + * adding our own suffix to Etag headers when a negotiation is successful. + * * Author: Nicholas Cull <ru...@us...> * Date: 1 March 2004 *************** *** 81,92 **** * 0.9 ETag handled correctly for different content types. * - * Todo: - * - * Make sure Etag is handled correctly. I assume from - * http://www.w3.org/2003/01/xhtml-mimetype/content-negotiation - * that Etags should be unique for each content-type returned. This should - * be doable by intercepting requests containing If-None-Match headers - * and fixing up Etags on the way in, and by adding our own prefix to - * Etag headers on the way out. * * Directives: --- 85,88 ---- |
From: <ru...@us...> - 2004-03-11 13:26:27
|
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; |
From: <ru...@us...> - 2004-03-11 12:49:17
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6354 Modified Files: mod_xhtml_neg.c Log Message: ETag processing now working as intended. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** mod_xhtml_neg.c 11 Mar 2004 12:04:53 -0000 1.9 --- mod_xhtml_neg.c 11 Mar 2004 12:22:39 -0000 1.10 *************** *** 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: --- 79,83 ---- * 0.7 Added profile handling, fixed up default charset for text/xml * 0.8 First public release. ! * 0.9 ETag handled correctly for different content types. * * Todo: *************** *** 458,462 **** } ! static char *construct_new_etag( pool *p, int index ) { return ap_psprintf( p, "\"mxn-%d\"", index ); --- 458,467 ---- } ! /* ! * Construct an Etag suffix to be appended to the standard Apache ! * ETag. ! */ ! ! static char *construct_etag_suffix( pool *p, int index ) { return ap_psprintf( p, "\"mxn-%d\"", index ); *************** *** 825,829 **** static char *best_match(pool *p, array_header *accept_type, array_header *content_type, array_header *accept_charset, ! int stars_to_match, xhtml_neg_state *xns) { float best_q = 0.0f; --- 830,835 ---- static char *best_match(pool *p, array_header *accept_type, array_header *content_type, array_header *accept_charset, ! int stars_to_match, xhtml_neg_state *xns, ! int *result_index) { float best_q = 0.0f; *************** *** 837,840 **** --- 843,849 ---- char *logmessage; + /* Set result index to 0 initially. */ + *result_index = 0; + /* Deal with silly null pointers when Accept: header is empty */ if((content_type == NULL) || (accept_type == NULL)) { *************** *** 891,894 **** --- 900,904 ---- best_stars = curr_stars; best_type = curr_content; + *result_index = i + 1; } } *************** *** 948,951 **** --- 958,962 ---- extension_rec *item; table *hdrs; + int *result_index; conf = (xhtml_dir_config *) ap_get_module_config( *************** *** 1036,1042 **** accept_charsets = do_accept_charset_line(r->pool, accept_charset); result_type = best_match( r->pool, accept_types, content_types, accept_charsets, conf->stars_ignore, ! xns ); if( result_type != NULL ) { --- 1047,1055 ---- accept_charsets = do_accept_charset_line(r->pool, accept_charset); + /* Allocate storage for index of result, used in Etag. */ + result_index = (int *) ap_palloc( r->pool, sizeof(int)); result_type = best_match( r->pool, accept_types, content_types, accept_charsets, conf->stars_ignore, ! xns, result_index ); if( result_type != NULL ) { *************** *** 1045,1049 **** * by Apache. */ ! char *new_etag = construct_new_etag( r->pool, 4 ); r->vlist_validator = new_etag; r->content_type = result_type; --- 1058,1062 ---- * by Apache. */ ! char *new_etag = construct_etag_suffix( r->pool, *result_index ); r->vlist_validator = new_etag; r->content_type = result_type; |
From: <ru...@us...> - 2004-03-11 12:31:31
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3487 Modified Files: mod_xhtml_neg.c Log Message: Reworked and simplified ETag handling. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** mod_xhtml_neg.c 11 Mar 2004 09:52:02 -0000 1.8 --- mod_xhtml_neg.c 11 Mar 2004 12:04:53 -0000 1.9 *************** *** 79,92 **** * 0.7 Added profile handling, fixed up default charset for text/xml * 0.8 First public release. ! * 0.82 Development of ETag handling. * * Todo: * ! * Make sure ETag is handled correctly. I assume from * http://www.w3.org/2003/01/xhtml-mimetype/content-negotiation ! * that ETags should be unique for each content-type returned. This should * be doable by intercepting requests containing If-None-Match headers ! * and fixing up ETags on the way in, and by adding our own prefix to ! * ETag headers on the way out. * * Directives: --- 79,92 ---- * 0.7 Added profile handling, fixed up default charset for text/xml * 0.8 First public release. ! * 0.82 Development of Etag handling. * * Todo: * ! * Make sure Etag is handled correctly. I assume from * http://www.w3.org/2003/01/xhtml-mimetype/content-negotiation ! * that Etags should be unique for each content-type returned. This should * be doable by intercepting requests containing If-None-Match headers ! * and fixing up Etags on the way in, and by adding our own prefix to ! * Etag headers on the way out. * * Directives: *************** *** 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. --- 158,161 ---- *************** *** 471,474 **** --- 458,466 ---- } + static char *construct_new_etag( pool *p, int index ) + { + return ap_psprintf( p, "\"mxn-%d\"", index ); + } + /* * For a given filename, scan through an array of extension_rec records *************** *** 585,648 **** /* - * Following code modified from mod_negotiate.c - * - * Get a single ETag entry --- one quoted string with optional - * "weak" prefix. - */ - - static const char *get_etag(pool *p, etag_rec *result, - const char *accept_line) - { - char *token, *end; - - result->weak = 0; - result->etag = ""; - - /* - * Note that this handles the format: - * - * If-None-Match: "etag-1", W/"etag2", "etag3" - * - * If the token begins with a "W/", we're looking at a weak - * mnodifier, otherwise we parse the quoted ETag immediately - */ - - token = ap_get_token(p, &accept_line, 0); - - if( *token == 'W' || *token == 'w' ) { - ++token; - result->weak = 1; - /* Skip the slash */ - if( *token != '\0' ) { - ++token; - } - } - - if (*token == '"') { - ++token; - for (end = token; - (*end && *end != '\n' && *end != '\r' && *end != '\"'); - end++); - } else { - for (end = token; (*end && !ap_isspace(*end)); end++); - } - if (*end) { - *end = '\0'; /* strip ending quote or return */ - } - - /** Assign the ETag to the parsed token */ - result->etag = token; - - if (*accept_line == ',') { - ++accept_line; - } - - return accept_line; - } - - /* * Dealing with Accept header lines ... * ! * The Accept request header is handled by do_header_line() - it has the * basic structure of a list of items of the format: * --- 577,583 ---- /* * Dealing with Accept header lines ... * ! * The Accept request header is handled by do_accept_line() - it has the * basic structure of a list of items of the format: * *************** *** 657,661 **** */ ! static array_header *do_header_line(pool *p, const char *accept_line) { array_header *accept_recs; --- 592,596 ---- */ ! static array_header *do_accept_line(pool *p, const char *accept_line) { array_header *accept_recs; *************** *** 1091,1095 **** (content_accept ? content_accept : ""), "\n", "Accept charset is: ", ! (accept_charset ? accept_charset : ""), "\n", NULL); write(xns->log_fd, logmessage, mod_xhtml_strlen( logmessage )); --- 1026,1031 ---- (content_accept ? content_accept : ""), "\n", "Accept charset is: ", ! (accept_charset ? accept_charset : ""), "\n", ! NULL); write(xns->log_fd, logmessage, mod_xhtml_strlen( logmessage )); *************** *** 1097,1101 **** /* Translate into content arrays. */ ! accept_types = do_header_line(r->pool, content_accept); accept_charsets = do_accept_charset_line(r->pool, accept_charset); --- 1033,1037 ---- /* Translate into content arrays. */ ! accept_types = do_accept_line(r->pool, content_accept); accept_charsets = do_accept_charset_line(r->pool, accept_charset); *************** *** 1105,1112 **** if( result_type != NULL ) { r->content_type = result_type; if( xns->log_fd > 0 ) { logmessage = ap_pstrcat(r->pool, ! "Best content-type: ", result_type, "\n", NULL ); write(xns->log_fd, logmessage, mod_xhtml_strlen( logmessage )); } --- 1041,1057 ---- if( result_type != NULL ) { + /* Construct a "suffix" for the ETag, and make sure it gets + * appended to the ETag that would normally be returned + * by Apache. + */ + char *new_etag = construct_new_etag( r->pool, 4 ); + r->vlist_validator = new_etag; r->content_type = result_type; + if( xns->log_fd > 0 ) { logmessage = ap_pstrcat(r->pool, ! "Best content-type: ", result_type, "\n", ! "New Etag is: ", new_etag, "\n", ! NULL ); write(xns->log_fd, logmessage, mod_xhtml_strlen( logmessage )); } *************** *** 1134,1206 **** } - /* - * 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... */ --- 1079,1082 ---- *************** *** 1418,1422 **** xhtml_negotiate, /* fixups */ NULL, /* logger */ ! xhtml_fixup_etags, /* header parser */ NULL, /* child_init */ NULL, /* child_exit */ --- 1294,1298 ---- xhtml_negotiate, /* fixups */ NULL, /* logger */ ! NULL, /* header parser */ NULL, /* child_init */ NULL, /* child_exit */ |
From: <ru...@us...> - 2004-03-11 10:18:38
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10476 Modified Files: mod_xhtml_neg.c Log Message: Added simple ETag parsing. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** mod_xhtml_neg.c 9 Mar 2004 10:20:27 -0000 1.7 --- mod_xhtml_neg.c 11 Mar 2004 09:52:02 -0000 1.8 *************** *** 585,588 **** --- 585,645 ---- /* + * Following code modified from mod_negotiate.c + * + * Get a single ETag entry --- one quoted string with optional + * "weak" prefix. + */ + + static const char *get_etag(pool *p, etag_rec *result, + const char *accept_line) + { + char *token, *end; + + result->weak = 0; + result->etag = ""; + + /* + * Note that this handles the format: + * + * If-None-Match: "etag-1", W/"etag2", "etag3" + * + * If the token begins with a "W/", we're looking at a weak + * mnodifier, otherwise we parse the quoted ETag immediately + */ + + token = ap_get_token(p, &accept_line, 0); + + if( *token == 'W' || *token == 'w' ) { + ++token; + result->weak = 1; + /* Skip the slash */ + if( *token != '\0' ) { + ++token; + } + } + + if (*token == '"') { + ++token; + for (end = token; + (*end && *end != '\n' && *end != '\r' && *end != '\"'); + end++); + } else { + for (end = token; (*end && !ap_isspace(*end)); end++); + } + if (*end) { + *end = '\0'; /* strip ending quote or return */ + } + + /** Assign the ETag to the parsed token */ + result->etag = token; + + if (*accept_line == ',') { + ++accept_line; + } + + return accept_line; + } + + /* * Dealing with Accept header lines ... * |
From: <ru...@us...> - 2004-03-09 10:45:27
|
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 */ |
From: <ru...@us...> - 2004-03-08 21:16:54
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16464 Modified Files: mod_xhtml_neg.c Log Message: Added comment to explain why we send Vary or Cache-control headers even if we don't find a match. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** mod_xhtml_neg.c 8 Mar 2004 10:13:07 -0000 1.5 --- mod_xhtml_neg.c 8 Mar 2004 20:52:20 -0000 1.6 *************** *** 79,82 **** --- 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: *************** *** 1045,1048 **** --- 1046,1053 ---- } + /* Note that whether or not this module successfully identifies + * a negotiated response, we should always send the appropriate + * Vary or cache-control response. + */ if(r->proto_num < HTTP_VERSION(1,1)) { /* Really shouldn't cache responses for HTTP 1.0 or earlier. |
From: <ru...@us...> - 2004-03-08 10:38:14
|
Update of /cvsroot/mod-xhtml-neg/CVSROOT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9686 Removed Files: syncmail Log Message: Removed local syncmail. --- syncmail DELETED --- |
From: <ru...@us...> - 2004-03-08 10:37:21
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9448 Modified Files: mod_xhtml_neg.c Log Message: Added a todo in the module-level comments about ETag and its effects. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mod_xhtml_neg.c 8 Mar 2004 10:03:18 -0000 1.4 --- mod_xhtml_neg.c 8 Mar 2004 10:13:07 -0000 1.5 *************** *** 80,86 **** * 0.8 First public release. * ! * Directives: * ! * Valid directives are: * * XhtmlNegActive Is this module enabled? Defaults to no. --- 80,93 ---- * 0.8 First public release. * ! * Todo: * ! * Make sure ETag is handled correctly. I assume from ! * http://www.w3.org/2003/01/xhtml-mimetype/content-negotiation ! * that ETags should be unique for each content-type returned. This should ! * be doable by intercepting requests containing If-None-Match headers ! * and fixing up ETags on the way in, and by adding our own prefix to ! * ETag headers on the way out. ! * ! * Directives: * * XhtmlNegActive Is this module enabled? Defaults to no. |