You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Sander van Zoest <sa...@yahoo-inc.com> on 2002/05/16 20:06:43 UTC
[PATCH] 1.3.X mod_headers: New Directive "ErrorHeader"
It is common practice to set Cookie's to pass along on HTTP
redirects for "login" authentication.
When implementing P3P <http://www.w3.org/P3P/> using
mod_headers.c the Header directive only sets r->headers_out
and does not pass the headers along for non-2XX responses
such as error pages and redirects.
To provide this functionality we added the ErrorHeader
directive which populates r->err_headers_out instead.
Below follows a patch for 1.3.X by Michael Radwin.
I have some code that attempts to add Directive to 2.0.X, but
it seems that output_filters are shortcuted on 3XX responses.
While now by setting the Header directive it also passes the headers
along at for all non-2XX responses except 3XX responses.
Cheers,
--
Sander van Zoest +1 (619) 881-3000
Yahoo!, Inc. sander@yahoo-inc.com
<http://www.yahoo.com/> <http://sander.vanzoest.com/>
Index: apache-1.3/src/modules/standard/mod_headers.c
===================================================================
RCS file: /work/cvs/root/asf/httpd/apache-1.3/src/modules/standard/mod_headers.c,v
retrieving revision 1.27
diff -u -p -r1.27 mod_headers.c
--- apache-1.3/src/modules/standard/mod_headers.c 13 Mar 2002 21:05:33 -0000 1.27
+++ apache-1.3/src/modules/standard/mod_headers.c 16 May 2002 04:41:08 -0000
@@ -116,6 +116,7 @@ typedef struct {
hdr_actions action;
char *header;
char *value;
+ int do_err;
} header_entry;
/*
@@ -128,6 +129,9 @@ typedef struct {
module MODULE_VAR_EXPORT headers_module;
+static char c_err;
+#define HDR_ERR &c_err
+
static void *create_headers_config(pool *p, server_rec *s)
{
headers_conf *a =
@@ -169,6 +173,12 @@ static const char *header_cmd(cmd_parms
new = (header_entry *) ap_push_array(serverconf->headers);
}
+ if (cmd->info == HDR_ERR) {
+ new->do_err = 1;
+ } else {
+ new->do_err = 0;
+ }
+
if (!strcasecmp(action, "set"))
new->action = hdr_set;
else if (!strcasecmp(action, "add"))
@@ -200,6 +210,8 @@ static const command_rec headers_cmds[]
{
{"Header", header_cmd, NULL, OR_FILEINFO, TAKE23,
"an action, header and value"},
+ {"ErrorHeader", header_cmd, HDR_ERR, OR_FILEINFO, TAKE23,
+ "an action, header and value"},
{NULL}
};
@@ -209,18 +221,19 @@ static void do_headers_fixup(request_rec
for (i = 0; i < headers->nelts; ++i) {
header_entry *hdr = &((header_entry *) (headers->elts))[i];
+ table *tbl = (hdr->do_err ? r->err_headers_out : r->headers_out);
switch (hdr->action) {
case hdr_add:
- ap_table_addn(r->headers_out, hdr->header, hdr->value);
+ ap_table_addn(tbl, hdr->header, hdr->value);
break;
case hdr_append:
- ap_table_mergen(r->headers_out, hdr->header, hdr->value);
+ ap_table_mergen(tbl, hdr->header, hdr->value);
break;
case hdr_set:
- ap_table_setn(r->headers_out, hdr->header, hdr->value);
+ ap_table_setn(tbl, hdr->header, hdr->value);
break;
case hdr_unset:
- ap_table_unset(r->headers_out, hdr->header);
+ ap_table_unset(tbl, hdr->header);
break;
}
}
@@ -264,5 +277,7 @@ module MODULE_VAR_EXPORT headers_module
NULL, /* child_exit */
NULL /* post read-request */
};
+
+