How to get request body in varnish

I am currently working on a varnish-based project ..

we write vcl and vmod . But the project must check the body of the request. How can I get message request body in vcl or vmod using C function ?

+4
source share
2 answers

You can do almost anything you want with VCL / VMOD. You should try calling the VMOD routine in vcl_recv , and then write something like below in the C code:

  • Use VRT_GetHdr(rec->s, HDR_REQ, "\017Content-Length:"); for reading body length
  • Use HTC_Read(rec->s->htc, body, bodylen);

And enjoy it!

You should take a look at existing vmods https://www.varnish-cache.org/vmods and you can freely search for the varnish API sources.

+3
source

I'm not sure you can.

Lac usually only deals with Req / Resp headers. Bodies are transmitted without (significant) modification.

I will find a solution, please let me know how this interests me.

+1
source

Source: https://habr.com/ru/post/1380728/


All Articles