Pull Hash_data into header

Guillaume Quintard guillaume at varnish-software.com
Tue Jul 2 22:12:03 UTC 2019


Hi,

This is because req.hash is a BLOB, and isn't coverted implicitly into a
string. Good news is you have access to vmod_blob that's bundled with
varnish.

Here a self-contained test, you can run it using "varnishtest foo.vtc":

varnishtest "req.hash example"

server s1 {
  rxreq
  txresp
} -start

varnish v1 -vcl+backend {
  import blob;
  sub vcl_deliver {
    set resp.http.hash = blob.encode(HEX, blob=req.hash);
  }
} -start


client c1 {
  txreq -url /url/1
  rxresp
  expect resp.http.hash ==
"fd1d762b1bfbb23067ee15d0d0a8b026d51a99147b26d01f95215b4b277d6e8f"
} -run


Three things to note:
- vsl_mask only enable the logging side of things, so it's independent from
the VCL code
- please show us an error message, "it doesn't work" isn't an amazing
explanation of what failed
- while a bit hardcore, you usually can look at
https://github.com/varnishcache/varnish-cache/tree/master/bin/varnishtest/tests
for
VCL examples

cheers,
-- 
Guillaume Quintard


On Tue, Jul 2, 2019 at 1:50 PM L Cruzero <lcruzero at gmail.com> wrote:

> Hi,
>
> I'm trying to put hash_data info onto a header for debugging purposes:
>
> varnishd -V
> varnishd (varnish-plus-6.0.3r6 revision
> bd7ae68d24df8ec166bd40b47726313c235b70a1)
>
> I'm able to see the hash values via varnishlog after setting these startup
> parameters:  DAEMON_OPTS=" -p vsl_mask=+Hash"
>
> -   VCL_return     hash
> -   VCL_call       HASH
> -   Hash           "/ps01/3000_complete.m3u8%00"
> -   Hash           "/ps01/3000_complete.m3u8%00"
>
> however I'm not able to load the data onto a header under sub vcl_deliver
> with:
>
> set resp.http.X.MY-DEBUG = req.http.X-MY-DEBUG + " HASH: "  + req.hash;
>
>
>
>
> Thanks,
> Luis
>
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20190702/4ec2393d/attachment.html>


More information about the varnish-misc mailing list