Now that 4.1 is out of the way, I'd like to push this.

Comments?
From 6518ca56029c5d28dec2830854e402fad9897764 Mon Sep 17 00:00:00 2001
From: "Federico G. Schwindt" <[email protected]>
Date: Thu, 1 Oct 2015 11:06:07 +0100
Subject: [PATCH] Convert arguments to strings as well

This is consistent with what we do in other cases.
---
 bin/varnishtest/tests/d00003.vtc | 27 ++++++++++++++++-----------
 lib/libvcc/vcc_expr.c            |  3 +++
 2 files changed, 19 insertions(+), 11 deletions(-)

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.",
-- 
2.5.3

_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to