req->bereq

Nils Goroll slink at schokola.de
Tue Oct 30 13:14:50 UTC 2018


Hi,

Somewhat related to the objvar vmods, I've been pondering how best get PRIV_TASK
based custom state across the req/bereq boundary.

How about a sub vcl_backend_init {} with read-access to req.* and write-access
to bereq.* ? This would be called when we prepare the bereq before continuing
with the req.

For vmods, there could be a VRT_priv_task_req variant which allows read-only
access to the req PRIV_TASK state. With such an interface, vmods could implement
methods to copy over objects from the client side, for example

vcl_init {
	new foo = taskvar.int();	# exists
}

sub vcl_recv {
	foo.set(42);			# exists
}

sub vcl_backend_init {
	foo.inherit();			# new
}

sub vcl_backend.fetch {
	set bereq.http.foo = foo.get(); # exists, should give 42
}

Nils


More information about the varnish-dev mailing list