Dynamically creating strings in inline c for use in the VRT_SetHdr function

Trystan Leftwich trystanleftwich at gmail.com
Tue Oct 30 00:11:04 CET 2012

Hi all,

I have a few questions about using VRT_SetHdr function. I'm sure some
of this is due to lack of c experience so I apologize if this is the

Firstly, Is there a way to create the header string dynamically. I
know the header string has to be in the format "\020X-Forwarded-For:",
it has to start with the length of the string in octal, But if I'm
creating the header name dynamically, Say if i wanted to create
separate headers based of GeoIP data or something similar, How could I
go about creating the string so It matches the format?

I've tried to overwrite the first byte of the header string to be the
length of the rest of the header string as an unsigned int, which will
work to the extent that Varnish passes all of the asserts it and will
display the page correctly, But the header itself will be incorrect,
it seems like the browser is trying to  convert the integer to a char
and ends up just displaying and an empty box and the string itself.

And secondly, purely out of interest, Could someone explain why the
header is prefixed with its length in octal? Does it have something to
do with correctly setting the amount of memory needed?



More information about the varnish-misc mailing list