[master] ebad1cf Make beresp.filters writable, and test it.
Poul-Henning Kamp
phk at FreeBSD.org
Wed Apr 18 07:56:11 UTC 2018
commit ebad1cff8a221ef11010f25384b0eaa40c175899
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Apr 18 07:54:56 2018 +0000
Make beresp.filters writable, and test it.
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 1706c98..b316cec 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -540,9 +540,6 @@ vbf_default_filter_list(const struct busyobj *bo, struct vsb *vsb)
if (do_gzip && !is_gunzip)
do_gzip = 0;
- /* But we can't do both at the same time */
- assert(do_gzip == 0 || do_gunzip == 0);
-
if (do_gunzip || (is_gzip && bo->do_esi))
VSB_cat(vsb, " gunzip");
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 0ab6286..52adc63 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -927,3 +927,21 @@ VRT_r_beresp_filters(VRT_CTX)
/* We do not set bo->filter_list yet, things might still change */
return (VBF_Get_Filter_List(ctx->bo));
}
+
+VCL_VOID
+VRT_l_beresp_filters(VRT_CTX, const char *str, ...)
+{
+ va_list ap;
+ const char *b;
+
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
+ va_start(ap, str);
+ b = VRT_String(ctx->bo->ws, NULL, str, ap);
+ va_end(ap);
+ if (b == NULL) {
+ WS_MarkOverflow(ctx->bo->ws);
+ return;
+ }
+ ctx->bo->filter_list = b;
+}
diff --git a/bin/varnishtest/tests/g00003.vtc b/bin/varnishtest/tests/g00003.vtc
index 1ba77ba..74bfa58 100644
--- a/bin/varnishtest/tests/g00003.vtc
+++ b/bin/varnishtest/tests/g00003.vtc
@@ -27,6 +27,12 @@ server s1 {
expect req.http.accept-encoding == <undef>
txresp -hdr "Vary: Accept-Encoding" \
-body "keep plain real"
+
+ rxreq
+ expect req.url == "/filters"
+ expect req.http.accept-encoding == <undef>
+ txresp -bodylen 78
+
} -start
varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend {
@@ -36,6 +42,9 @@ varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend {
if (bereq.url == "/foobar") {
set beresp.do_gzip = true;
}
+ if (bereq.url == "/filters") {
+ set beresp.filters = "gzip gunzip gzip gunzip gzip";
+ }
}
} -start
@@ -62,6 +71,8 @@ client c1 {
expect resp.bodylen == 43
} -run
+varnish v1 -vsl_catchup
+
varnish v1 -expect n_gzip == 1
varnish v1 -expect n_gunzip == 2
varnish v1 -expect n_test_gunzip == 0
@@ -80,3 +91,13 @@ client c1 {
expect resp.http.content-encoding == <undef>
expect resp.body == "keep plain real"
} -run
+
+varnish v1 -vsl_catchup
+
+client c1 {
+ txreq -url /filters
+ rxresp
+ expect resp.http.content-encoding == "gzip"
+ gunzip
+ expect resp.bodylen == 78
+} -run
diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst
index f29a9ed..c1b765c 100644
--- a/doc/sphinx/reference/vcl_var.rst
+++ b/doc/sphinx/reference/vcl_var.rst
@@ -901,6 +901,8 @@ beresp.filters
Readable from: vcl_backend_response
+ Writable from: vcl_backend_response
+
List of VFP filters the beresp.body will be pulled through.
obj
More information about the varnish-commit
mailing list