--- /dev/null
+# $Id$
+
+test "Test VCL regsub()"
+
+server s1 {
+ rxreq
+ txresp \
+ -hdr "Foobar: barf" \
+ -hdr "Connection: close" \
+ -body "012345\n"
+}
+
+varnish v1 -vcl+backend {
+ sub vcl_fetch {
+ set obj.http.Snafu1 = regsub(obj.http.Foobar, "ar", "&&");
+ set obj.http.Snafu2 =
+ regsub(obj.http.Foobar, "(b)(a)(r)(f)", "$4$3$2p");
+ set obj.http.Snafu3 =
+ regsub(obj.http.Foobar, "(b)(a)(r)(f)", "$4\$$3$2p");
+ set obj.http.Snafu4 =
+ regsub(obj.http.Foobar, "(b)(a)(r)(f)", "$4\&$3$2p");
+ set obj.http.Snafu5 =
+ regsub(obj.http.Foobar, "(b)(a)(r)(f)", "$$$4$3$2\$p");
+ }
+} -start
+
+server s1 -start
+
+client c1 {
+ txreq -url "/"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.X-Varnish == "1001"
+ expect resp.http.foobar == "barf"
+ expect resp.http.snafu1 == "bararf"
+ expect resp.http.snafu2 == "frap"
+ expect resp.http.snafu3 == "f$rap"
+ expect resp.http.snafu4 == "f&rap"
+ expect resp.http.snafu5 == "barffra$p"
+}
+
+client c1 -run