c06.vtc 2.95 KB
Newer Older
Geoff Simmons's avatar
Geoff Simmons committed
1 2 3 4 5 6 7 8 9 10 11 12 13
varnishtest "limit to backrefs 0 to 10 with dynamic matches"

# same as c05.vtc with match_dyn()

server s1 {
	rxreq
	txresp -hdr "Foo: 12345678901" -hdr "Bar: 123456789012" -body "1111\n"
} -start

varnish v1 -vcl+backend {
	import re from "${vmod_topbuild}/src/.libs/libvmod_re.so";

	sub vcl_backend_response {
14
		if (re.match_dyn("(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)",
Geoff Simmons's avatar
Geoff Simmons committed
15
				      beresp.http.foo)) {
16 17 18 19 20 21 22 23 24 25 26 27
			set beresp.http.foo0 = re.backref_dyn(0, "error0");
			set beresp.http.foo1 = re.backref_dyn(1, "error1");
			set beresp.http.foo2 = re.backref_dyn(2, "error2");
			set beresp.http.foo3 = re.backref_dyn(3, "error3");
			set beresp.http.foo4 = re.backref_dyn(4, "error4");
			set beresp.http.foo5 = re.backref_dyn(5, "error5");
			set beresp.http.foo6 = re.backref_dyn(6, "error6");
			set beresp.http.foo7 = re.backref_dyn(7, "error7");
			set beresp.http.foo8 = re.backref_dyn(8, "error8");
			set beresp.http.foo9 = re.backref_dyn(9, "error9");
			set beresp.http.foo10 = re.backref_dyn(10, "error10");
			set beresp.http.foo11 = re.backref_dyn(11, "fallback");
Geoff Simmons's avatar
Geoff Simmons committed
28 29 30
		} else {
			set beresp.status = 999;
		}
31
		if (re.match_dyn("(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)",
Geoff Simmons's avatar
Geoff Simmons committed
32
				       beresp.http.bar)) {
33 34 35 36 37 38 39 40 41 42 43 44
			set beresp.http.bar0 = re.backref_dyn(0, "error0");
			set beresp.http.bar1 = re.backref_dyn(1, "error1");
			set beresp.http.bar2 = re.backref_dyn(2, "error2");
			set beresp.http.bar3 = re.backref_dyn(3, "error3");
			set beresp.http.bar4 = re.backref_dyn(4, "error4");
			set beresp.http.bar5 = re.backref_dyn(5, "error5");
			set beresp.http.bar6 = re.backref_dyn(6, "error6");
			set beresp.http.bar7 = re.backref_dyn(7, "error7");
			set beresp.http.bar8 = re.backref_dyn(8, "error8");
			set beresp.http.bar9 = re.backref_dyn(9, "error9");
			set beresp.http.bar10 = re.backref_dyn(10, "error10");
			set beresp.http.bar11 = re.backref_dyn(11, "fallback");
Geoff Simmons's avatar
Geoff Simmons committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
		} else {
			set beresp.status = 999;
		}
	}

} -start

client c1 {
	txreq
	rxresp
	expect resp.status == 200
	expect resp.http.foo0 == "1234567890"
	expect resp.http.foo1 == "1"
	expect resp.http.foo2 == "2"
	expect resp.http.foo3 == "3"
	expect resp.http.foo4 == "4"
	expect resp.http.foo5 == "5"
	expect resp.http.foo6 == "6"
	expect resp.http.foo7 == "7"
	expect resp.http.foo8 == "8"
	expect resp.http.foo9 == "9"
	expect resp.http.foo10 == "0"
	expect resp.http.foo11 == "fallback"
	expect resp.http.bar0 == "12345678901"
	expect resp.http.bar1 == "1"
	expect resp.http.bar2 == "2"
	expect resp.http.bar3 == "3"
	expect resp.http.bar4 == "4"
	expect resp.http.bar5 == "5"
	expect resp.http.bar6 == "6"
	expect resp.http.bar7 == "7"
	expect resp.http.bar8 == "8"
	expect resp.http.bar9 == "9"
	expect resp.http.bar10 == "0"
	expect resp.http.bar11 == "fallback"
} -run

logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
	expect 0 * Begin req
Nils Goroll's avatar
Nils Goroll committed
84 85 86
	expect * = VCL_Error {^vmod re: backref \d+ out of range$}
	expect * = VCL_Error {^vmod re: capturing substrings exceed max \d+}
	expect * = VCL_Error {^vmod re: backref \d+ out of range$}
Geoff Simmons's avatar
Geoff Simmons committed
87 88
	expect * = End
} -run