--- /Users/jerome/Downloads/softs/apache-trunk/modules/metadata/mod_expires.c 2009-09-14 15:57:55.000000000 +0200 +++ /Users/jerome/Downloads/softs/apache-trunk/modules/metadata/mod_expires.c 2009-09-15 23:08:18.000000000 +0200 @@ -167,6 +167,7 @@ typedef struct { int active; + int ignore_redirect; int wildcards; char *expiresdefault; apr_table_t *expiresbytype; @@ -180,6 +181,9 @@ #define ACTIVE_OFF 0 #define ACTIVE_DONTCARE 2 +#define IGNORE_REDIRECT_YES 1 +#define IGNORE_REDIRECT_NO 0 + module AP_MODULE_DECLARE_DATA expires_module; static void *create_dir_expires_config(apr_pool_t *p, char *dummy) @@ -187,6 +191,7 @@ expires_dir_config *new = (expires_dir_config *) apr_pcalloc(p, sizeof(expires_dir_config)); new->active = ACTIVE_DONTCARE; + new->ignore_redirect = IGNORE_REDIRECT_NO; new->wildcards = 0; new->expiresdefault = NULL; new->expiresbytype = apr_table_make(p, 4); @@ -204,6 +209,18 @@ if (arg == 0) { dir_config->active = ACTIVE_OFF; } + + return NULL; +} + +static const char *set_expiresignoreredirect(cmd_parms *cmd, void *in_dir_config, const char *code) +{ + expires_dir_config *dir_config = in_dir_config; + + if(strcmp(code, "Yes") == 0) { + dir_config->ignore_redirect = IGNORE_REDIRECT_YES; + } + return NULL; } @@ -358,6 +375,8 @@ "a MIME type followed by an expiry date code"), AP_INIT_TAKE1("ExpiresDefault", set_expiresdefault, NULL, DIR_CMD_PERMS, "an expiry date code"), + AP_INIT_TAKE1("ExpiresIgnoreRedirect", set_expiresignoreredirect, NULL, DIR_CMD_PERMS, + "Wether to ignore Location headers or not, possible values 'Yes' or 'No', default is 'No'"), {NULL} }; @@ -383,6 +402,9 @@ new->wildcards = add->wildcards; new->expiresbytype = apr_table_overlay(p, add->expiresbytype, base->expiresbytype); + + new->ignore_redirect = add->ignore_redirect; + return new; } @@ -459,6 +481,19 @@ conf = (expires_dir_config *) ap_get_module_config(r->per_dir_config, &expires_module); + /* Found a "Location" header, do not send "Expires" */ + if(conf->ignore_redirect == IGNORE_REDIRECT_NO) { + if(apr_table_get(r->err_headers_out, "Location") != NULL) { + ap_remove_output_filter(f); + return ap_pass_brigade(f->next, b); + } + + if(apr_table_get(r->headers_out, "Location") != NULL) { + ap_remove_output_filter(f); + return ap_pass_brigade(f->next, b); + } + } + /* * Check to see which output header table we should use; * mod_cgi loads script fields into r->err_headers_out, @@ -566,4 +601,4 @@ NULL, /* merge server configs */ expires_cmds, /* command apr_table_t */ register_hooks /* register hooks */ -}; +};