Changes with Apache 2.0.41
+ *) mod_rewrite can now sets cookies in err_headers, and uses the correct
+ expiry date. PR 12132
+ [Ian Holsman / Rob Cromwell <apachechangelog@robcromwell.com>]
+
*) The content-length filter no longer tries to buffer up
the entire output of a long-running request before sending
anything to the client. [Brian Pane]
if (var && val && domain) {
/* FIX: use cached time similar to how logging does it */
- cookie = apr_pstrcat( r->pool,
- var,
- "=",
- val,
- "; path=/; domain=",
- domain,
- (expires)? "; expires=" : NULL,
- (expires)? ap_ht_time(r->pool,
- r->request_time +
- (60 * atol(expires)),
- "%a, %d-%b-%Y %T GMT", 1)
- : NULL,
- NULL);
-
+ request_rec *rmain = r;
+ char *notename;
+ char *data;
+ while (rmain->main) {
+ rmain = rmain->main;
+ }
- /*
- * XXX: should we add it to err_headers_out as well ?
- * if we do we need to be careful that only ONE gets sent out
- */
- apr_table_add(r->headers_out, "Set-Cookie", cookie);
- rewritelog(r, 5, "setting cookie '%s' to '%s'", var, val);
+ notename = apr_pstrcat(rmain->pool, var, "_rewrite", NULL);
+ apr_pool_userdata_get( &data, notename, rmain->pool);
+ if (data== NULL) {
+ cookie = apr_pstrcat(rmain->pool,
+ var,
+ "=",
+ val,
+ "; path=/; domain=",
+ domain,
+ (expires)? "; expires=" : NULL,
+ (expires)?
+ ap_ht_time(r->pool,
+ r->request_time +
+ apr_time_from_sec((60 *
+ atol(expires))),
+ "%a, %d-%b-%Y %T GMT", 1)
+ : NULL,
+ NULL);
+ /*
+ * XXX: should we add it to err_headers_out as well ?
+ * if we do we need to be careful that only ONE gets sent out
+ */
+ apr_table_add(rmain->err_headers_out, "Set-Cookie", cookie);
+ apr_pool_userdata_set("set", notename, NULL, rmain->pool);
+ rewritelog(rmain, 5, "setting cookie '%s' to '%s'", var, val);
+ }
+ else {
+ rewritelog(rmain, 5, "cookie '%s' is already set..skipping", var);
+ }
}
}
}