Bug 40899 - additional mod_headers enhancements - regex & fmt specifiers
Summary: additional mod_headers enhancements - regex & fmt specifiers
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_headers (show other bugs)
Version: 2.5-HEAD
Hardware: All All
: P5 minor (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
Keywords: PatchAvailable
Depends on:
Reported: 2006-11-05 14:49 UTC by Tom Donovan
Modified: 2009-12-26 16:26 UTC (History)
0 users

mod_headers_enh.diff (9.40 KB, patch)
2006-11-05 14:52 UTC, Tom Donovan
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Donovan 2006-11-05 14:49:34 UTC
Suggested patch to make minor enhancements to mod_headers.

This is in addition to: Revision 452330, Oct 3 2006  by niq - 
  "Support regexp-based manipulation of HTTP headers"

1. Allow hdr= which works much like env=.  Inspects a request header when used
with RequestHeader, inspects  a response header when used with Header.

Not a big deal for RequestHeader because SetEnvIf can sometimes be used.
More useful with Header because SetEnvIf cannot inspect response headers.

2. Allow either env= or hdr= to optionally contain a regex to match the value, e.g.
      Header add MyHeader somethingNew env=myVariable~[a-z]123
will add a new header only if the environment variable myVariable exists and its
value contains a lowercase letter followed by "123".

3. Adds 5 new format specifiers in addition to %t and %D.  time (1) and duration
(2) without the "t=" or "D=" strings, time in RFC822 fmt (3), hostname (4),
servername (5).

4. Lots of module comments (which might help the doc effort)

Pls feel free to close or select any useful bits of this patch.  

An example of a situation which might use this is
(...Not related to this patch - I just happened to notice this post...)

This code has been pretty well exercised with 2.2.3, but only limited testing
with trunk.   The patch is for the trunk as of Nov 5, 2006.
Comment 1 Tom Donovan 2006-11-05 14:52:09 UTC
Created attachment 19089 [details]

mod_headers patch - based on trunk/modules/metadata/mod_headers.c - Nov 5, 2006
Comment 2 Nick Kew 2009-12-26 16:26:55 UTC
Tom, you've got commit since submitting this patch, so you can pursue it if you're still interested.

Closing this PR because most of it is superseded in trunk by switching the condition-processing to ap_expr in place of what you enhanced.  The format stuff would benefit from a similar effort, as noted by wrowe in a comment to Bug 47447