On Tue, 4 Mar 2014 07:40:48 +0100
Willy Tarreau <w...@1wt.eu> wrote:

> Hi,
> 
> On Mon, Mar 03, 2014 at 09:12:27PM +0100, PiBa-NL wrote:
> > Hi,
> > 
> > Im not sure if this is the exact issue that Anup was having, and maybe 
> > i'm hijacking his thread, if so i'm sorry for that, but when try to 
> > check how it works i also having difficulties getting it to work as i 
> > expected it to.
> > 
> > I'm using HAProxy v1.5dev21 on FreeBSD 8.3.
> > 
> > Ive written in a frontend the following which checks for a GET web 
> > request to determine which backend to use, this works..:
> > mode tcp
> > tcp-request inspect-delay 5s
> > acl PAYLOADcheck req.payload(0,3) -m bin 474554
> > use_backend web_80_tcp if PAYLOADcheck
> > tcp-request content accept if PAYLOADcheck
> > 
> > However when changing the match line to the following it fails:
> > acl PAYLOADcheck req.payload(0,3) -m str GET
> > or
> > acl PAYLOADcheck req.payload(0,3) -m sub GET
> > or
> > acl PAYLOADcheck req.payload(0,3) -m reg -i GET
> > 
> > The req.payload returns a piece of 'binary' data, but the 'compatibility 
> > matrix' seems to say that converting for use with sub/reg/others should 
> > not be an issue.
> > 
> > Then the next step is of course to not match only the first 3 characters 
> > but some content further in the 'middle' of the data stream..
> > 
> > Am i missing something ? Or might there be an issue with the implementation?
> 
> What you've done is absolutely correct. It is possible that there's a
> bug somewhere in the cast. I'm CCing Thierry who has a pending patch
> set of about 50 patches to rework ACLs (merge ACL+map and allow to update
> them on-the-fly) to ensure he checks this case.
> 


The match "bin" get the configuration string "474554" and convert it as
the binary sequence "GET". The match "str" get the configuration string
"GET" and use it as is.

The fetch "req.payload()" returns a binary content. When you try to
match with "str" method, the binary content is converted as string. The
converter produce string representing hexadecimal content: "474554".

If you write 

   acl PAYLOADcheck req.payload(0,3) -m str 474554

The system works perfectly.

This behavior is not intuitive. Maybe it can be change later.

Thierry



Reply via email to