Hi Jim,

[side note: please guys, avoid top-posting, it makes it very difficult
 to quote context in responses]

On Mon, Apr 17, 2023 at 09:17:03PM -0600, Jim Freeman wrote:
> Aleksandar - thanks for the feedback ! (haproxy -vv : attached)
> 
> I'd spent a good long while scouring the config docs (and Google) seeking
> enlightenment, but ...
> No joy using either of '! -m found -m int 0' or '! -m found'.
> 
> Here's hoping someone/anyone else has experience making an empty field()
> work ...
(...)

So my understanding based on the below:

> > > cookie: cook2hdr=#####
> > > bar: bar
> > > baz: baz
> > > meta: ,bar,baz
> > > foo:
> > > ===
> > > when foo: should not be created, and meta: should only have 2 fields.
> > >
> > > Am I just getting the idiom/incantation wrong ?

is that you are trying to match an empty string, that's it ? So you'd
like to match that "foo" is empty and that "meta" would iterate over
empty, "bar", "baz". It's not directly related to fields() in this case
as fields() will return the requested fields. The problem seems from
not being able to match against an empty pattern. What I'm seeing
generally for this is "-m len 0" to match a string of length zero.
Others prefer to match against regex "." (which will check for the
presence of at least one character).

Just a warning below though:

> > >    acl COOK_META_MISSING  req.cook(cook2hdr),field(3,\#) ! -m found -m 
> > > str ''

I have no idea how that parses to be honest, because a single match
method may be used and normally whatever follows the first pattern are
other patterns. Since the "found" match doesn't take any pattern, it's
likely that "-m str ''" is still parsed and possibly replaces -m found,
but I wouldn't count on that.

So if you want to consider as missing a cookie that is either not present
or that is empty, I would probably do it this way:

    acl COOK_META_MISSING  req.cook(cook2hdr),field(3,\#) ! -m found
    acl COOK_META_MISSING  req.cook(cook2hdr),field(3,\#) -m len 0

This ACL will be true if the cookie's value was not found, or if it
was found but with an empty length.

hoping this helps,
Willy

Reply via email to