Panic message: Assert error in http_IsHdr() with varnish version 3.0

Varnish version 3 is fairly old and new versions are out there and ready to use. If you are still using varnish version 3 and facing the following issue:

Panic message: Assert error in http_IsHdr(), cache_http.c line 167:#012  Condition(l == strlen(hdr + 1)) not true.

Solution:
The above error is thrown by varnish bacause it is expecting a valid octal number when the header is either get/set using the following method:

        char *user_product = VRT_GetHdr(sp, HDR_RESP, "\033X-Cookie-Value-productCode:");

In the above function call the octal value is 033. The octal value is calculated based on this "X-Cookie-Value-productCode:" string. The length of the string is 27 (decimal) and the octal value of that is: 33 

If we set the octal value correct then the header get/set will work flawlessly.

Following is one set header call inside a subroutine under C block:

        VRT_SetHdr(sp, HDR_RESP, "\026X-Is-Valid-Subscriber:", "true", vrt_magic_string_end);

Once the header is set in C block and it can be easily accesible using following syntax: 

resp.http.X-Is-Valid-Subscriber
 








Comments