On Fri, Jan 24, 2020 at 10:26:34AM +0100, Christopher Faulet wrote:
> Le 24/01/2020 à 09:17, Willy Tarreau a écrit :
> > On Fri, Jan 24, 2020 at 08:28:33AM +0100, Christopher Faulet wrote:
> > > Le 23/01/2020 à 19:59, James Brown a écrit :
> > > > I spent a couple of minutes and made the attached (pretty bad) patch to
> > > > add a del-header-by-prefix.
> > > >
> > >
> > > Just an idea. Instead of adding a new action, it could be cleaner to
> > > extend
> > > the del-header action adding some keywords. Something like:
> > >
> > > http-request del-header begin-with <prefix>
> > > http-request del-header end-with <sufix>
> > > http-request del-header match <regex>
> > >
> > > It could be also extended to replace-header and replace-value actions.
> >
> > I would also prefer to extend existing syntax, however it's problematic
> > to insert optional words *before* arguments. This will complicate the
> > parsing, and even config manipulation scripts.
> >
> > That's why I thought we could instead just append an extra optional
> > keyword appended after the name, eventhough it's less elegant.
> >
>
> From the configuration parsing point of view, it is more or less the same
> thing. You must test if the second argument is defined or not. And in fact,
> moving it after the header name is not a "better" solution because there is
> an optional condition too at the end. So this one will not be the last one.
No, it's more complicated this way because you have to check each and every
word to figure the syntax. Example: how do you mention that you want to
remove the header field matching regex "unless" ? You'd have to do this :
http-request del-header match unless
And it's ambiguous, as it can either mean :
- delete header name "match" unless a condition which needs to be parsed,
and once figured invalid, you can roll back ;
- delete header described by regex "unless" with no condition
When you do it the other way around it's way easier, because the name
always being the first argument makes sure the second one is limited to
a small subset (match/prefix/if/unless for example):
http-request del-header unless match
A variant of this could be to use the same syntax as the options we already
use on ACL matches, which are "-m reg", "-m beg", "-m end". But these will
also need to be placed after to avoid the same ambiguity (since "-m" is a
token hence a valid header name). That would give for example :
http-request del-header server
http-request del-header x-private- -m beg
http-request del-header x-.*company -m reg
http-request del-header -tracea -m end
Willy