httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Rhodes <>
Subject mod_headers: changes to support direct HTTP header mapping (+Vary)
Date Thu, 25 Aug 2005 14:08:08 GMT
[resend since it kinda missed everyone the first time]


I've been using mod_headers extensively for a number of years to modify
headers from as they enter and exit the network. We use apache as a
front end to our appservers and we get requests from multiple sources so
we often have issues with header translation. This means we have to do
something like this:

  RewriteCond %{HTTP:INPUTHEADER1}  ([0-9]+)
  RewriteRule (.*) $1 [E=HEADER:%1]

  RewriteCond %{HTTP:INPUTHEADER2}  ([0-9]+)
  RewriteCond %{ENV:HEADER}         (.+)
  RewriteRule (.*) $1 [E=HEADER:%1]

  RewriteCond %{ENV:HEADER}         (.+)
  RewriteRule (.*) $1 [E=HEADER:"default"]

  RequestHeader set OUTPUTHEADER %{HEADER}e env=HEADER

This has worked kind of ok until now, but we are now looking at caching
issues and wish to ensure that the corresponding Vary is mapped. This
makes the situation somewhat more complicated and I don't think it's
really possible to continue doing this via rewrite rules.

I've looked at mod_headers and have started implementing a patch. The
patch provides the following functionality:

  Header|RequestHeader default <Header> <Value>

  The header <Header> is only set if <Header> does not already exist.

  Header|RequestHeader copy <New-Header> <Original-Header>

  This will copy the value of <Original-Header> to <New-Header> if and
only if <New-Header> is not already present.

  Header|RequestHeader rename <New-Header> <Original-Header>

  This will copy the value of <Original-Header> to <New-Header> if and
only if <New-Header> is not already present. In addition to this it will
remove <Original-Header>.

The combination of the above will allow me to put something like the

  RequestHeader default "default"

This is obviously neater, but the main reason to do this is to have an
explicit link between the headers so that when a response comes back,
the Vary can be catered for. So if 'Vary: OUTPUTHEADER' is sent back
from the appserver, apache can convert this to 'Vary: INPUTHEADER1' or
'Vary: INPUTHEADER2' as appropriate.

Ok. That is a lot of background, but my question is what is the best way
to track which of the translations took place? I was trying to avoid
bodging it with setting an environment variable or using notes. Is there
somewhere within the datastructures where I can keep track of which
rules fired?

Also, I have made an effort to genericise this implementation so it fits
logically on top of mod_headers. Is there any possibility that such a
patch might be commited for mod_headers?

thanks in advance,


View raw message