[4.1] abc86a8 Convert arguments to strings as well

Lasse Karstensen lkarsten at varnish-software.com
Thu Jan 14 15:15:03 CET 2016


commit abc86a8a9f90c5cfc4e849413efe22ffc1c31ec3
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Thu Oct 1 11:06:07 2015 +0100

    Convert arguments to strings as well
    
    This is consistent with what we do in other cases.

diff --git a/bin/varnishtest/tests/d00003.vtc b/bin/varnishtest/tests/d00003.vtc
index 0c95d61..56b3035 100644
--- a/bin/varnishtest/tests/d00003.vtc
+++ b/bin/varnishtest/tests/d00003.vtc
@@ -5,6 +5,8 @@ server s1 {
 	txresp -hdr "Foo: 1" -body "1"
 	rxreq
 	txresp -hdr "Foo: 3" -body "3"
+	rxreq
+	txresp -hdr "Foo: 9" -body "9"
 } -start
 
 server s2 {
@@ -28,19 +30,18 @@ varnish v1 -vcl+backend {
 	}
 
 	sub vcl_recv {
-		return(pass);
-	}
-
-	sub vcl_backend_fetch {
-		if (bereq.url == "/nohdr") {
-			set bereq.backend = h1.backend(bereq.http.Void);
-		} else if (bereq.url == "/emptystring") {
-			set bereq.backend = h1.backend("");
-		} else if (bereq.url == "/13") {
-			set bereq.backend = h1.backend(bereq.http.Void + "" + bereq.url);
+		if (req.url == "/nohdr") {
+			set req.backend_hint = h1.backend(req.http.Void);
+		} else if (req.url == "/emptystring") {
+			set req.backend_hint = h1.backend("");
+		} else if (req.url == "/13") {
+			set req.backend_hint = h1.backend(req.http.Void + "" + req.url);
+		} else if (req.url == "/ip") {
+			set req.backend_hint = h1.backend(client.ip);
 		} else {
-			set bereq.backend = h1.backend(bereq.url);
+			set req.backend_hint = h1.backend(req.url);
 		}
+		return (pass);
 	}
 } -start
 
@@ -68,4 +69,8 @@ client c1 {
 	txreq -url /nohdr
 	rxresp
 	expect resp.http.foo == "8"
+
+	txreq -url /ip
+	rxresp
+	expect resp.http.foo == "9"
 } -run
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 294d12a..b498a53 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -626,6 +626,9 @@ vcc_do_arg(struct vcc *tl, struct func_arg *fa)
 	} else {
 		vcc_expr0(tl, &e2, fa->type);
 		ERRCHK(tl);
+		if (e2->fmt != fa->type &&
+		    (fa->type == STRING || fa->type == STRING_LIST))
+			vcc_expr_tostring(tl, &e2, fa->type);
 		if (e2->fmt != fa->type) {
 			VSB_printf(tl->sb, "Wrong argument type.");
 			VSB_printf(tl->sb, "  Expected %s.",



More information about the varnish-commit mailing list