Re: Integrating a third party library

2015-02-26 Thread Willy Tarreau
On Thu, Feb 26, 2015 at 08:30:45AM +0100, Baptiste wrote:
> >> and 2. how
> >> could we write a new function in HAProxy which takes a buffer of data in
> >> entry and can return a string (or buffer of data)
> >
> > I think that what you want to implement is a sample fetch function. For
> > example, take a look at the recently introduced "req.hdr_names" function,
> > which iterates over all request headers and produces a string that can be
> > used to build a log line, another header or whatever. I think it will be
> > straightforward enough for you to understand how to implement this with
> > your lib.
> >
> > Best regards,
> > Willy
> >
> 
> Hi Willy,
> 
> I think a converter is more suited here.
> I mean, a fetch can't take a buffer issued from the result of an other 
> fetch...
> The idea would to configure it something like
>   http-request set-header Foobar
> req.hdr(HEADER),mikefunction()

That's precisely what I don't find clear in Mike's description. Since he
said "take a buffer of data", I assumed "use whatever is in the buffer",
and then that's what a fetch does. Of course if it's just to convert
strings or so, a converter is better, but that's not my understanding
here.

> Mike, in such case, you want to have a look at this file:
>   http://git.haproxy.org/?p=haproxy.git;a=blob_plain;f=src/sample.c;hb=HEAD
> and with the upper and lower and any other converter functions.

Absolutely.

Hopfully Mike will show us what he projected to do once it's done !

Willy




Re: Integrating a third party library

2015-02-25 Thread Baptiste
>> and 2. how
>> could we write a new function in HAProxy which takes a buffer of data in
>> entry and can return a string (or buffer of data)
>
> I think that what you want to implement is a sample fetch function. For
> example, take a look at the recently introduced "req.hdr_names" function,
> which iterates over all request headers and produces a string that can be
> used to build a log line, another header or whatever. I think it will be
> straightforward enough for you to understand how to implement this with
> your lib.
>
> Best regards,
> Willy
>

Hi Willy,

I think a converter is more suited here.
I mean, a fetch can't take a buffer issued from the result of an other fetch...
The idea would to configure it something like
  http-request set-header Foobar
req.hdr(HEADER),mikefunction()

Mike, in such case, you want to have a look at this file:
  http://git.haproxy.org/?p=haproxy.git;a=blob_plain;f=src/sample.c;hb=HEAD
and with the upper and lower and any other converter functions.

Baptiste



Re: Integrating a third party library

2015-02-25 Thread Willy Tarreau
Hi Mike,

On Wed, Feb 25, 2015 at 09:41:35AM +, Mike Zoom wrote:
> Hi everyone!
> 
> I want to integrate a third party library, open source, under the Mozilla
> Public licence v2.
> 
> The main role of this library is to process an HTTP request header and to
> return a string which describes the client.

OK.

> Basically, we have the following questions:
> 1. how could we link our library in HAProxy at compilation time,

You just want this lib to be optional, as we do with zlib, openssl, pcre etc.
Just patch the makefile to add "USE_XYZ=1" to enable it, and possibly pass
"XYZ_INC" and "XYZ_LIB" to point to the libs' sources when they're not in the
system's default path.

> and 2. how
> could we write a new function in HAProxy which takes a buffer of data in
> entry and can return a string (or buffer of data)

I think that what you want to implement is a sample fetch function. For
example, take a look at the recently introduced "req.hdr_names" function,
which iterates over all request headers and produces a string that can be
used to build a log line, another header or whatever. I think it will be
straightforward enough for you to understand how to implement this with
your lib.

Best regards,
Willy




Integrating a third party library

2015-02-25 Thread Mike Zoom
Hi everyone!

I want to integrate a third party library, open source, under the Mozilla
Public licence v2.

The main role of this library is to process an HTTP request header and to
return a string which describes the client.

Basically, we have the following questions:
1. how could we link our library in HAProxy at compilation time, and 2. how
could we write a new function in HAProxy which takes a buffer of data in
entry and can return a string (or buffer of data)

Thanks a lot for your help,
Mike