[mod-xhtml-neg-cvs] mod_xhtml_neg-2.0 mod_xhtml_neg.c,1.3,1.4
Brought to you by:
run2000
From: <ru...@us...> - 2004-03-15 03:18:25
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26891 Modified Files: mod_xhtml_neg.c Log Message: Hook into the handler now, to make sure we always send the correct result for 200 and 304 HTTP codes. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** mod_xhtml_neg.c 13 Mar 2004 09:27:13 -0000 1.3 --- mod_xhtml_neg.c 15 Mar 2004 03:09:23 -0000 1.4 *************** *** 573,578 **** */ ! static extension_rec *get_extension_for_filename( apr_array_header_t *extensions, ! const char *filename ) { extension_rec *list, *item; --- 573,578 ---- */ ! static extension_rec *get_extension_for_filename( ! apr_array_header_t *extensions, const char *filename ) { extension_rec *list, *item; *************** *** 697,701 **** */ ! static apr_array_header_t *do_accept_line(apr_pool_t *p, const char *accept_line) { apr_array_header_t *accept_recs; --- 697,702 ---- */ ! static apr_array_header_t *do_accept_line(apr_pool_t *p, ! const char *accept_line) { apr_array_header_t *accept_recs; *************** *** 930,934 **** static accept_rec *best_match(apr_array_header_t *accept_type, ! apr_array_header_t *content_type, apr_array_header_t *accept_charset, int stars_to_match, xhtml_neg_state *xns) { --- 931,936 ---- static accept_rec *best_match(apr_array_header_t *accept_type, ! apr_array_header_t *content_type, ! apr_array_header_t *accept_charset, int stars_to_match, xhtml_neg_state *xns) { *************** *** 1044,1053 **** /* ! * The actual content-negotiation phase of this module goes here... */ int xhtml_negotiate(request_rec *r) { ! apr_array_header_t *extensions, *accept_types, *accept_charsets, *content_types; const char *content_accept, *accept_charset; char *filename, *extension, *logmessage; --- 1046,1061 ---- /* ! * The actual content-negotiation phase of this module goes here. ! * ! * Note that due to the way we hook into the Apache handler system means ! * we always return DECLINED, even though handling was a success. ! * We do this so that the default handler will always run, and so that ! * ETag is handled correctly for both 200 OK and 304 Not Modified cases. */ int xhtml_negotiate(request_rec *r) { ! apr_array_header_t *extensions, *accept_types, ! *accept_charsets, *content_types; const char *content_accept, *accept_charset; char *filename, *extension, *logmessage; *************** *** 1072,1076 **** /* Only service requests for GET or HEAD methods. */ if( r->method_number != M_GET ) { ! return OK; } --- 1080,1084 ---- /* Only service requests for GET or HEAD methods. */ if( r->method_number != M_GET ) { ! return DECLINED; } *************** *** 1078,1082 **** hdrs = r->headers_in; if( hdrs == NULL ) { ! return OK; } --- 1086,1090 ---- hdrs = r->headers_in; if( hdrs == NULL ) { ! return DECLINED; } *************** *** 1084,1088 **** filename = r->filename; if( mod_xhtml_strempty( filename )) { ! return OK; } --- 1092,1096 ---- filename = r->filename; if( mod_xhtml_strempty( filename )) { ! return DECLINED; } *************** *** 1098,1102 **** content_types = item->content_types; } else { ! return OK; } --- 1106,1110 ---- content_types = item->content_types; } else { ! return DECLINED; } *************** *** 1142,1150 **** * 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 ); if( xns->log_fd != NULL ) { --- 1150,1158 ---- * by Apache. */ ! char *etag = merge_validators( r->pool, r->vlist_validator, result_rec->hashcode ); r->content_type = reconstruct_content_type( r->pool, result_rec ); + r->vlist_validator = etag; + ap_set_etag(r); if( xns->log_fd != NULL ) { *************** *** 1177,1220 **** } ! return OK; ! } ! ! /* 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... */ --- 1185,1192 ---- } ! return DECLINED; } /* All Apache configuration file code goes here... */ *************** *** 1322,1326 **** */ ! static const char *add_xhtml_log(cmd_parms *cmd, void *dummy, const char *logfile) { xhtml_neg_state *xns; --- 1294,1299 ---- */ ! static const char *add_xhtml_log(cmd_parms *cmd, void *dummy, ! const char *logfile) { xhtml_neg_state *xns; *************** *** 1435,1439 **** 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); --- 1408,1413 ---- 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); *************** *** 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); } --- 1424,1428 ---- { ap_hook_post_config(init_xhtml_log, NULL, NULL, APR_HOOK_MIDDLE); ! ap_hook_handler(xhtml_negotiate, NULL, NULL, APR_HOOK_FIRST); } |