|
NAMEvmod_bodyaccess - Varnish Module for request body access SYNOPSISimport bodyaccess [as name] [from "path"] INT rematch_req_body(REGEX re) VOID hash_req_body() INT len_req_body() VOID log_req_body(STRING prefix, INT length) DESCRIPTIONVarnish module that lets you access the request body. VCL example: vcl 4.0;
import std;
import bodyaccess;
backend default { .host = "192.0.2.11"; .port = "8080"; }
sub vcl_recv {
N.B. The request body must be retrieved before doing any operations on it. It can be buffered using the cache_req_body() function from libvmod_std. These functions applies only to standard REST methods. Caching is not allowed on PUT requests. INT rematch_req_body(REGEX re)
| std.cache_req_body(1KB);
|
| if (bodyaccess.rematch_req_body("FOO") == 1) {
| std.log("is true");
| }
VOID hash_req_body()
| sub vcl_recv {
| std.cache_req_body(1KB);
| }
|
| sub vcl_hash{
| bodyaccess.hash_req_body();
| }
INT len_req_body()
| std.cache_req_body(1KB); | set req.http.x-len = bodyaccess.len_req_body(); VOID log_req_body(STRING prefix="", INT length=200)
| std.cache_req_body(1KB);
| bodyaccess.log_req_body("PREFIX:", 3);
|