Mailing List Archive

how to create variables
"How can I create string variables in the default.vcl file... Is it
possible to create variables and then use them.."

alternatively,

" Is it possible to use the vcl variables in the inline c code and
vice-versa ? "


Thanks,
Arun
Re: how to create variables [ In reply to ]
Hi,

> "How can I create string variables in the default.vcl file... Is it
> possible to create variables and then use them.."

you can store informationen in the http-header

in vcl:
req.http.X-Variable = "value";

and in inline c
VRT_GetHdr(sp, HDR_REQ, "\013X-Variable:")

VRT_SetHdr(sp, HDR_REQ, "\013X-Variable:", "value", vrt_magic_string_end);

Sincerely

_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: how to create variables [ In reply to ]
Hi Arun,

On Wed, May 23, 2012 at 2:42 PM, Arun Dobriyal <arundobriyaliitkgp@gmail.com
> wrote:

> "How can I create string variables in the default.vcl file... Is it
> possible to create variables and then use them.."
>

Have a look at Tollefs excellent Variable VMOD.

https://www.varnish-cache.org/vmod/variable-support

Also, as Tobias mentioned. The old school way is to stuff things into HTTP
headers. :-)
--
Per Buer
Phone: +47 21 98 92 61 / Mobile: +47 958 39 117 / Skype: per.buer
*Varnish makes websites fly!*
Whitepapers <http://www.varnish-software.com/whitepapers> |
Video<http://www.youtube.com/watch?v=x7t2Sp174eI> |
Twitter <https://twitter.com/varnishsoftware>
Re: how to create variables [ In reply to ]
Thanks Per and Tobias.. http headers is a good way :)



On Thu, May 24, 2012 at 12:32 AM, Per Buer <perbu@varnish-software.com>wrote:

> Hi Arun,
>
> On Wed, May 23, 2012 at 2:42 PM, Arun Dobriyal <
> arundobriyaliitkgp@gmail.com> wrote:
>
>> "How can I create string variables in the default.vcl file... Is it
>> possible to create variables and then use them.."
>>
>
> Have a look at Tollefs excellent Variable VMOD.
>
> https://www.varnish-cache.org/vmod/variable-support
>
> Also, as Tobias mentioned. The old school way is to stuff things into HTTP
> headers. :-)
> --
> Per Buer
> Phone: +47 21 98 92 61 / Mobile: +47 958 39 117 / Skype: per.buer
> *Varnish makes websites fly!*
> Whitepapers <http://www.varnish-software.com/whitepapers> | Video<http://www.youtube.com/watch?v=x7t2Sp174eI> |
> Twitter <https://twitter.com/varnishsoftware>
>
>
>


--
Arun Dobriyal,
Fifth year Dual Degree Student,
Department of Computer Science and Engineering,
Indian Institute of Technology, Kharagpur,
India.
Re: how to create variables [ In reply to ]
I myself was having trouble with vmods, for the people who are looking at
the vmods for the first time,
probably the better way to understand them is by writing the vcl file and
running "varnishd" with "-C" option,
this option shows the c code generated for the vcl logic written in the
default.vcl file..
by this method, one can easily check how the vcl code is converted into its
corresponding c code,
and it would serve as a big help so as how to use/introduce variables in
vcl logic.

-Arun