Cookie value compare, integer

Lane, Richard rlane at ahbelo.com
Wed Nov 16 19:53:05 CET 2011


I am currently on Varnish 2.1.5. Looks like that vmod_std module was added in 3.x version. I was hoping to avoid getting into writing C code for this. Any other ideas?

>
> I am getting the value of a cookie and then trying to compare it to another
> integer value but am getting a compile error. Can I compare integers stored
> in the req object? Should I be going about this a different way?

Use the conversion method in vmod_std:
https://www.varnish-cache.org/docs/trunk/reference/vmod_std.html#integer

--
Andreas


On 11/16/11 6:06 AM, "Lane, Richard" <rlane at ahbelo.com> wrote:

Is anyone comparing cookie values that are integers?

I am getting the value of a cookie and then trying to compare it to another integer value but am getting a compile error. Can I compare integers stored in the req object? Should I be going about this a different way?

For example:

--sitename.vcl

sitename_recv{

    set req.http.compareVal=10;
    set req.http.cookieVal=5;

   call cookieValCompare;

}

sub cookieValCompare{

     if( req.http.cookieVal < req.http.compareVal)
    {
       #do something extra
    }
}


If I try to compile via the console I get:

Message from VCC-compiler:
Expected ')' got '<'
(program line 109), at
(/etc/varnish/sitename.vcl Line 11 Pos 28)
      if( req.http.cookieVal < req.http.compareVal )
---------------------------------#-----------------------------
Running VCC-compiler failed, exit 1VCL compilation failed
Command failed with error code 106

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20111116/75fe6b99/attachment-0003.html>


More information about the varnish-misc mailing list