[master] d6127c3e4 Teach libvcc how to set HEADER += STRING_LIST;

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Dec 2 12:14:07 UTC 2019


commit d6127c3e4332bfd9ccb6b5edf777f040d1db776b
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue Nov 5 19:24:12 2019 +0100

    Teach libvcc how to set HEADER += STRING_LIST;
    
    And avoid the indentation of characters in vcc_assign_expr().
    
    Fixes #3079
    Closes #3100

diff --git a/bin/varnishtest/tests/r03079.vtc b/bin/varnishtest/tests/r03079.vtc
new file mode 100644
index 000000000..5da83f91f
--- /dev/null
+++ b/bin/varnishtest/tests/r03079.vtc
@@ -0,0 +1,25 @@
+varnishtest "set VCL_??? += VCL_STRING;"
+
+server s1 {
+	rxreq
+	expect req.url == "/hello/world"
+	expect req.http.host == helloworld
+	txresp -hdr "x-powered-by: varnishtest"
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_backend_fetch {
+		set bereq.url += "/world";
+		set bereq.http.host += "world";
+	}
+	sub vcl_backend_response {
+		set beresp.http.x-powered-by += bereq.http.x-varnish;
+	}
+} -start
+
+client c1 {
+	txreq -url "/hello" -hdr "host: hello"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.x-powered-by == varnishtest1002
+} -run
diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c
index 30b6eef31..515a47a18 100644
--- a/lib/libvcc/vcc_action.c
+++ b/lib/libvcc/vcc_action.c
@@ -82,6 +82,7 @@ static const struct assign {
 	{ DURATION,	0,		DURATION },
 	{ STRING,	T_INCR,		STRING_LIST, "\v,\n" },
 	{ STRING,	'=',		STRING_LIST },
+	{ HEADER,	T_INCR,		STRING_LIST, "VRT_GetHdr(ctx, \v),\n" },
 	{ HEADER,	'=',		STRING_LIST },
 	{ BODY,		'=',		STRING_LIST },
 	{ VOID,		'=',		VOID }
@@ -98,9 +99,9 @@ vcc_assign_expr(struct vcc *tl, struct symbol *sym, const struct assign *ap)
 
 	while (*e != '\0') {
 		if (*e == '\v')
-			Fb(tl, 1, "%s", sym->rname);
+			Fb(tl, 0, "%s", sym->rname);
 		else
-			Fb(tl, 1, "%c", *e);
+			Fb(tl, 0, "%c", *e);
 		e++;
 	}
 }


More information about the varnish-commit mailing list