Hi Syohey,<div><br></div><div>Thanks for your answer.</div><div><br></div><div>My final goal is to get the hash calculated by Varnish. In the documentation of the 3.0.2 version it is written that req.hash contains this hash. I guess they just forgot to remove it and that req.hash doesn't exist anymore.</div>
<div><br></div><div>However, is there a mean to get the <b>final</b> hash calculated by varnish, the result of hash_data()?<br><br>Here: <a href="https://www.varnish-cache.org/docs/trunk/phk/varnish_does_not_hash.html">https://www.varnish-cache.org/docs/trunk/phk/varnish_does_not_hash.html</a> it is written:</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><span style="color:rgb(34,34,34);line-height:20px;text-align:justify;background-color:rgb(255,255,255)"><font face="arial, helvetica, sans-serif"><br></font></span></div>
<div><span style="color:rgb(34,34,34);line-height:20px;text-align:justify;background-color:rgb(255,255,255)"><font face="arial, helvetica, sans-serif">"All the strings hash_data() are fed, are pushed through a cryptographic hash algorithm called SHA256, which, as the name says, always spits out 256 bits (= 32 bytes), no matter how many bits you feed it."</font></span></div>
<div style="text-align:justify"><font color="#222222" face="arial, helvetica, sans-serif"><span style="line-height:20px"><br></span></font></div></blockquote><font color="#222222" face="arial, helvetica, sans-serif"><span style="line-height:20px">And that's what I am looking for, the final value of the hash. I guess I could do it myself with a bit of C, but I would think that it is possible to get this value from somewhere since Varnish already does the calculation.</span></font><div>
<font color="#222222" face="arial, helvetica, sans-serif"><span style="line-height:20px"><br></span></font></div><div><font color="#222222" face="arial, helvetica, sans-serif"><span style="line-height:20px">-Hugues<br></span></font><div>
<br><div class="gmail_quote">On Fri, Feb 10, 2012 at 5:22 PM, <a href="mailto:gau@gprj.net">gau@gprj.net</a> <span dir="ltr"><<a href="mailto:gau@gprj.net">gau@gprj.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hugues,<br>
<br>
req.hash is the original write-only.(If my memory serves me)<br>
and, VCL is a notation has changed Varnish3.<br>
req.hash is replaced to hash_data();<br>
<br>
<br>
 vcl:<br>
 sub vcl_hash {<br>
     hash_data(req.url);<br>
     set req.http.X-TEST = req.url; //add<br>
     if (req.http.host) {<br>
         hash_data(req.http.host);<br>
         set req.http.X-TEST = req.http.X-TEST + " + "  + req.http.host; //add<br>
     } else {<br>
        hash_data(server.ip);<br>
        set req.http.X-TEST = req.http.X-TEST + " + " + server.ip; //add<br>
     }<br>
     return (hash);<br>
 }<br>
<br>
<br>
  sub vcl_deliver{<br>
      set resp.http.X-TEST = req.http.X-TEST;<br>
  }<br>
<br>
 test:<br>
  wget  -d <a href="http://192.168.1.199:6081/test" target="_blank">http://192.168.1.199:6081/test</a> -O - > /dev/null<br>
<br>
  X-TEST: /test + <a href="http://192.168.1.199:6081" target="_blank">192.168.1.199:6081</a><br>
<br>
Is not a very smart.<br>
(Is not a hash, but understood what anything was used)<br>
<br>
<br>
Can not think only about making the other VMOD.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Syohei Tanaka(@xcir)<br>
<a href="http://xcir.net/" target="_blank">http://xcir.net/</a><br>
<br>
<br>
<br>
2012/2/11 Hugues Alary <<a href="mailto:hugues.alary@gmail.com">hugues.alary@gmail.com</a>>:<br>
</font></span><div class="HOEnZb"><div class="h5">> 2012/2/10 Roberto O. Fernández Crisial <<a href="mailto:roberto.fernandezcrisial@gmail.com">roberto.fernandezcrisial@gmail.com</a>><br>
>><br>
>> Hugues,<br>
><br>
><br>
> Hi Roberto,<br>
><br>
> Thank you for your answer.<br>
><br>
>><br>
>><br>
>> Try this:<br>
>><br>
>> set req.http.X-TEST = req.hash;<br>
>> set req.http.TEST = req.http.X-TEST;<br>
>><br>
>> It should work.<br>
><br>
><br>
><br>
> Unfortunately the problem doesn't come from the syntax of "req.http.TEST"<br>
> but from req.hash. Here is the message:<br>
><br>
> Message from VCC-compiler:<br>
> Symbol not found: 'req.hash' (expected type STRING_LIST):<br>
> ('input' Line 219 Pos 31)<br>
>         set req.http.X-TEST = req.hash;<br>
> ------------------------------########-<br>
><br>
> Running VCC-compiler failed, exit 1<br>
><br>
> VCL compilation failed<br>
><br>
><br>
> I also tried to put that in my configuration:<br>
><br>
> set req.http.X-TEST = {""} + req.hash;<br>
><br>
><br>
> And, same error:<br>
><br>
> Message from VCC-compiler:<br>
> Symbol not found: 'req.hash' (expected type STRING):<br>
> ('input' Line 219 Pos 38)<br>
>         set req.http.X-TEST = {""} + req.hash;<br>
> -------------------------------------########-<br>
><br>
> Running VCC-compiler failed, exit 1<br>
><br>
> VCL compilation failed<br>
><br>
><br>
> Do you have any other idea ?<br>
><br>
>><br>
>> Good  luck,<br>
>><br>
>> Roberto (@rofc)<br>
>><br>
><br>
> Thanks!<br>
> -Hugues<br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> _______________________________________________<br>
> varnish-misc mailing list<br>
> <a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
> <a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Hugues ALARY<br>
</div></div>