Changes in Varnish Cache 9.1·续
Changes to VCL#
-
The
req0.method,req0.url,req0.protoandreq0.http.*variables have been added for read access to the request almost exactly as it was originally received. Invrt.h,struct vrt_ctxgained thehttp_req0member andenum gethdr_egainedHDR_REQ0. -
Setting
req.max_age = 0snow forces a cache miss with request coalescing, where it previously had no effect. (4041) -
The HTTP
QUERYmethod has been added to the well known request methods and is passed by default in the builtin VCL. (4531) -
The new
resp.esi_include_onerrorvariable allows to override theesi_include_onerrorfeature flag invcl_deliver {}. (4054) -
The
synthetic()VCL action has been removed. Since Varnish Cache 5.0.0, body data can be created by settingberesp.bodyinvcl_backend_error {}and by settingresp.bodyinvcl_synth {}, and these continue to be available as the one way to create body data, as in these examples: -
set resp.body = "string" + " more strings";set resp.body += " appending even " + "more strings";set resp.body = :blob:;set resp.body += :blobappend:;
These examples equally work on beresp.body in vcl_backend_error {}.
The direct replacement for synthetic(<string>); is set resp.body += <string>; in vcl_synth {} and set beresp.body += <string>; in vcl_backend_error {}.
The only difference in behavior is that synthetic(<nullstring>) would create the string (null) for <nullstring> being a NULL pointer internally, while set resp.body = <nullstring> creates the empty string "" and set resp.body += <nullstring> is a NOOP. (4503)
- A new
resp.storageVCL variable available fromvcl_synth{}was added to select which storage the synth response body gets created on. (4358)
VMODs#
vmod_std#
-
Fixed a bug causing
std.fileread()to panic when pointed at a 0-length file. (4557) -
The argument to
std.rollback()is now obsolete and ignored, the appropriate headers to be rolled back are now inferred from the call site. This also fixes a panic whenresporberespwas passed. (4566) -
std.collect_all()has been added to combine all multiple headers ofreq,resp,bereqorberespaccording to the HTTP RFCs:Set-Cookieis not combined,Cookieis combined with"; "and all other headers with", ". -
Header combining by
std.collect()is now visible in the log. -
std.strftime()now errors out it given a NULL format string. (4551) -
Fixed a potential buffer over-read when parsing HTTP dates. (4554)
-
std.getenv()gained an optional fallback argument which is returned if the environment variable is not set. (4527)
vmod_math#
math.strfromd(): format strings cannot contain extra data after the formatter. (4547)
vmod_blob#
-
blob.transcode()now limits its stack usage by decoding large inputs piecemeal, avoiding a potential stack overflow. -
blob.sub()now properly errors out if given a negative offset or size. (4549)
varnishlog & varnishstat#
HttpGarbagelog records now contain the offending data rather than just the request method.- HTTP/1 messages rejected for invalid body framing now get a
BogoHeaderlog record naming the offending field. - Malformed lines in the VSM
_.indexfile are now reported with a meaningful diagnostic instead of a bare assertion failure in VSM readers likevarnishstatandvarnishlog. (4569) - Counters for backend connection closes have been added:
MAIN.backend_closed,MAIN.backend_closed_errand theMAIN.bc_*close reason counters that are a subset ofsc_*session counters, as well as the equivalent per-backendVBE.*.closed,VBE.*.closed_errand close reason counters. (4337) varnish{log,ncsa,hist,top}all gained the-0dry-run argument that allows validating command line arguments before running them for real. (4493)
varnishadm#
-
varnishadmnow only uses libedit if both stdin and stdout are terminals. -
The
-x workdiroption has been added tovarnishadmto print the default work directory and exit. This is useful for tools that need to discover the VSM location in most setups. (4494) -
tls.cert.list -jno longer returns an empty body with a200status when the child process is not running; it now returns an empty JSON array ([]).
varnishtest & vtest#
-
varnishtestgained theVTEST_VARNISH_VCL_PREPENDenvironment variable to inject VCL code into all VCL loaded byvarnishinstances. -
Varnish can now be built without the vtest2 git submodule and instead with an externally provided vtest program, as installed by running
DESTDIR=/prefix make installin the Vtest2 repository <https://code.vinyl-cache.org/vtest/VTest2> (#4398)
The Varnish specific test commands varnish, logexpect and vsm have been moved to a vtest extension.
For a build with the submodule, both a varnishtest program and vtest symlink continue to be built and installed as monolithic binaries which always include the extension.
For a build without the submodule (with an external vtest program), a varnishtest wrapper is built, which sets up the right command line arguments and calls vtest.
This is done to hopefully achieve a smooth transition, until we plan to eventually remove varnishtest and wholly replace it with vtest -E libvtest_ext_varnish.so (or the equivalent for automake), which is what the varnishtest wrapper already calls.
-
The following vtest
featuretests have been moved tovcache_builtwithin the Varnish Cache VTest extension:64bit,persistent_storage,coverage,asan,msan,tsan,ubsan,sanitizer,workspace_emulatorandwitness. -
In the Varnish Cache VTest extension, the log output of SLT_F_UNSAFE log records has been changed to escape unprintable characters as
\xFF, FF being the hexadecimal representation of the respective character. -
A simple perl script
tools/vtclog2logexp.shhas been added to help createlogexpcommands forvtestfrom its output.
Changes for developers and VMOD authors#
- We added infrastructure to easily build VMODs for multiple Varnish Cache based projects. Besides changing how VMOD builds discover such projects and configure themselves appropriately, we also added the
vcachecommand to the Varnish Cache VTest extension. (#4537)
With the same goal, cache/cache_vinyld.h has been renamed to cache/cache_int.h.
See Supporting multiple Varnish Cache based projects for details on how to migrate.
We also fixed the maxmimum version check in the VCACHE_REQUIRE macro from inclusive to exclusive, matching VARNISH_PREREQ's original documented behavior. So VCACHE_REQUIRE([varnish], [9.0.0], [9.1.0]) no longer implements "9.0.x OR 9.1.0" but rather "9.0.x".
-
The
varnish-legacy.m4macro collection for VMOD builds has been removed. VMODs should migrate to using the macros fromvarnish.m4. -
The
LBODY_SETandLBODY_ADDcompatibility defines and thestruct VCL_confandstruct VSC_maindeclarations have been removed fromvrt.h.struct vmod_datahas moved tovmod_abi.h.
The debug storage engine lost all parameters except dinit and dopen, as these are replaced by the above now.
Likewise, the debug.fragfetch helper parameter has been removed, vtc.storage_frag() fills its place.
-
VTIM_format()no longer usesgmtime_r(), which improves performance. -
The
Tstrcmp()macro has been removed fromvdef.h,Tstreq()is to be used for equality checks. -
The functions
VRT_synth_strands(),VRT_synth_blob(),VRT_synth_page()andVRT_Stv()have been removed from the runtime. -
STV_BanExport()no longer holds theban_mtx(3853)
