Learning C and VRT_SetHdr()

Dan dan at retrobadger.net
Thu Mar 31 15:25:13 CEST 2011


On 31/03/11 12:58, Cosimo Streppone wrote:
> On Thu, 31 Mar 2011 22:39:51 +1100, Dan <dan at retrobadger.net> wrote:
>
>> The snipper from my current code is:
>
> Is it correct to do this in all
> vcl_miss, pipe and pass?
> What about vcl_hit then?
>
> I would have expected this to happen in vcl_deliver()
> or vcl_fetch() if you want your backends to see
> the header you're setting.
>
> Anyway...
>
>> /sub detectmobile {/
>> /  C{/
>> /    VRT_SetHdr(sp, HDR_BEREQ, "\020X-Varnish-TeraWurfl:", "no1",
>> vrt_magic_string_end);/
>> /  }C/
>
> I believe you have a problem in the "\020" bit.
> That is octal notation.
>
> "X-Whatever:" is 11 bytes, including the ':',
> so you need to write:
>
>   "\013X-Whatever:"
>
> Have fun,
>

Sadly no luck with that, I have ammended my code as recommended.  
Varnish is still able to restart without errors, but WSOD on page load.  
My custom function is now something:

sub detectmobile {
   C{
     VRT_SetHdr(sp, HDR_BEREQ, "\013X-Varnish-TeraWurfl:", "no1", 
vrt_magic_string_end);
   }C
}

And the only occurance of 'call detectmobile;' is in:
sub vcl_deliver {}

Are there any libraries required for the VRT scripts to work?

Do I need to alter the /etc/varnish/default file for C to work in varnish?



More information about the varnish-misc mailing list