From: Graham Leggett Date: Sat, 14 Sep 2013 15:31:35 +0000 (+0000) Subject: mod_headers: Add 'Header note header-name note-name' to copy a headers X-Git-Tag: 2.4.7~219 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4fe9050604c5a848b9dafe56642d187b8651cc2c;p=apache mod_headers: Add 'Header note header-name note-name' to copy a headers value into a note (so a CGI/Proxy header can be deleted and logged) trunk patch: http://svn.apache.org/r1520908 Submitted by: covener Reviewed by: jim, humbedooh git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1523271 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 7beaef82a0..21c73741ad 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.4.7 + *) mod_headers: Add 'Header note header-name note-name' for copying a response + headers value into a note. [Eric Covener] + *) mod_headers: Add 'setifempty' command to Header and RequestHeader. [Eric Covener] diff --git a/STATUS b/STATUS index 4cd4395dba..6cac228d20 100644 --- a/STATUS +++ b/STATUS @@ -97,12 +97,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_headers: Add 'Header note header-name note-name' to copy a headers - value into a note (so a CGI/Proxy header can be deleted and logged) - trunk patch: http://svn.apache.org/r1520908 - 2.4.x patch: trunk works, if 1496338 above is merged first. - +1: covener, jim, humbedooh - PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/docs/manual/mod/mod_headers.xml b/docs/manual/mod/mod_headers.xml index 774cadc4f6..68ba926add 100644 --- a/docs/manual/mod/mod_headers.xml +++ b/docs/manual/mod/mod_headers.xml @@ -300,7 +300,7 @@ Header merge Cache-Control no-store env=NO_STORE Header Configure HTTP response headers -Header [condition] add|append|echo|edit|edit*|merge|set|unset +Header [condition] add|append|echo|edit|edit*|merge|set|unset|note header [value] [replacement] [early|env=[!]variable]|expr=expression] @@ -400,6 +400,13 @@ Header merge Cache-Control no-store env=NO_STORE
The response header of this name is removed, if it exists. If there are multiple headers of the same name, all will be removed. value must be omitted.
+ +
note
+
The value of the named response header is copied into an + internal note whose name is given by value. This is useful + if a header sent by a CGI or proxied resource is configured to be unset + but should also be logged.
+

This argument is followed by a header name, which diff --git a/modules/metadata/mod_headers.c b/modules/metadata/mod_headers.c index 6c03e71839..55cfb50a9b 100644 --- a/modules/metadata/mod_headers.c +++ b/modules/metadata/mod_headers.c @@ -96,8 +96,9 @@ typedef enum { hdr_unset = 'u', /* unset header */ hdr_echo = 'e', /* echo headers from request to response */ hdr_edit = 'r', /* change value by regexp, match once */ - hdr_edit_r = 'R', /* change value by regexp, everymatch */ - hdr_setifempty = 'i' /* set value if header not already present*/ + hdr_edit_r = 'R', /* change value by regexp, everymatch */ + hdr_setifempty = 'i', /* set value if header not already present*/ + hdr_note = 'n' /* set value of header in a note */ } hdr_actions; /* @@ -448,9 +449,11 @@ static APR_INLINE const char *header_inout_cmd(cmd_parms *cmd, new->action = hdr_edit; else if (!strcasecmp(action, "edit*")) new->action = hdr_edit_r; + else if (!strcasecmp(action, "note")) + new->action = hdr_note; else return "first argument must be 'add', 'set', 'setifempty', 'append', 'merge', " - "'unset', 'echo', 'edit', or 'edit*'."; + "'unset', 'echo', 'note', 'edit', or 'edit*'."; if (new->action == hdr_edit || new->action == hdr_edit_r) { if (subs == NULL) { @@ -796,6 +799,10 @@ static int do_headers_fixup(request_rec *r, apr_table_t *headers, apr_table_do(add_them_all, (void *) headers, ed.t, NULL); } break; + case hdr_note: + apr_table_setn(r->notes, process_tags(hdr, r), apr_table_get(headers, hdr->header)); + break; + } } return 1;