DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10772>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10772 [PATCH] RequestHeader directive for mod_headers.c Summary: [PATCH] RequestHeader directive for mod_headers.c Product: Apache httpd-1.3 Version: 1.3.26 Platform: All OS/Version: All Status: NEW Severity: Enhancement Priority: Other Component: mod_headers AssignedTo: bugs@httpd.apache.org ReportedBy: [EMAIL PROTECTED] Recently in a more complicated HA setup involving apache 1.3.xx we needed to be able to set additional headers in the request. This doesn't seem to be possible in 1.3.26. This patch adds a directive "RequestHeader" to mod_headers.c. The syntax is exactly as for "Header". --- mod_headers.c-2002-07-13 Wed Mar 13 21:05:33 2002 +++ mod_headers.c Sat Jul 13 12:57:38 2002 @@ -59,13 +59,19 @@ /* * mod_headers.c: Add/append/remove HTTP response headers * Written by Paul Sutton, [EMAIL PROTECTED], 1 Oct 1996 + * Updated with RequestHeader by Martin Algesten, + * [EMAIL PROTECTED], 13 Jul 2002. * * New directive, Header, can be used to add/replace/remove HTTP headers. * Valid in both per-server and per-dir configurations. + * In addition directive, RequestHeader, can be used exactly as Header but + * with the difference that the header is added to the request headers rather + * than the response. * * Syntax is: * - * Header action header value + * Header action header value + * RequestHeader action header value * * Where action is one of: * set - set this header, replacing any old value @@ -77,7 +83,7 @@ * Where action is unset, the third argument (value) should not be given. * The header name can include the colon, or not. * - * The Header directive can only be used where allowed by the FileInfo + * The directives can only be used where allowed by the FileInfo * override. * * When the request is processed, the header directives are processed in @@ -112,7 +118,15 @@ hdr_unset = 'u' /* unset header */ } hdr_actions; + +typedef enum { + hdrs_in = 'i', /* Add header to incoming (request) headers */ + hdrs_out = 'o' /* Add header to outgoing (response) headers */ +} hdrs_inout; + + typedef struct { + hdrs_inout inout; hdr_actions action; char *header; char *value; @@ -154,7 +168,7 @@ } -static const char *header_cmd(cmd_parms *cmd, headers_conf * dirconf, char *action, char *hdr, char *value) +static const char *header_cmd(cmd_parms *cmd, headers_conf * dirconf, char *action, char *hdr, char *value, hdrs_inout inout ) { header_entry *new; server_rec *s = cmd->server; @@ -169,6 +183,8 @@ new = (header_entry *) ap_push_array(serverconf->headers); } + new->inout = inout; + if (!strcasecmp(action, "set")) new->action = hdr_set; else if (!strcasecmp(action, "add")) @@ -196,33 +212,56 @@ return NULL; } +static const char *outheader_cmd(cmd_parms *cmd, headers_conf * dirconf, char *action, char *hdr, char *value) { + + header_cmd( cmd, dirconf, action, hdr, value, hdrs_out ); + +} + +static const char *inheader_cmd(cmd_parms *cmd, headers_conf * dirconf, char *action, char *hdr, char *value) { + + header_cmd( cmd, dirconf, action, hdr, value, hdrs_in ); + +} + static const command_rec headers_cmds[] = { - {"Header", header_cmd, NULL, OR_FILEINFO, TAKE23, + {"Header", outheader_cmd, NULL, OR_FILEINFO, TAKE23, + "an action, header and value"}, + {"RequestHeader", inheader_cmd, NULL, OR_FILEINFO, TAKE23, "an action, header and value"}, {NULL} }; static void do_headers_fixup(request_rec *r, array_header *headers) { - int i; + int i; table *t; for (i = 0; i < headers->nelts; ++i) { header_entry *hdr = &((header_entry *) (headers->elts))[i]; - switch (hdr->action) { - case hdr_add: - ap_table_addn(r->headers_out, hdr->header, hdr->value); - break; - case hdr_append: - ap_table_mergen(r->headers_out, hdr->header, hdr->value); - break; - case hdr_set: - ap_table_setn(r->headers_out, hdr->header, hdr->value); - break; - case hdr_unset: - ap_table_unset(r->headers_out, hdr->header); - break; - } + switch (hdr->inout) { + case hdrs_out: + t = r->headers_out; + break; + case hdrs_in: + t = r->headers_in; + break; + } + switch (hdr->action) { + case hdr_add: + ap_table_addn(t, hdr->header, hdr->value); + break; + case hdr_append: + ap_table_mergen(t, hdr->header, hdr->value); + break; + case hdr_set: + ap_table_setn(t, hdr->header, hdr->value); + break; + case hdr_unset: + ap_table_unset(t, hdr->header); + break; + } + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]