Commit f0232502 authored by Nils Goroll's avatar Nils Goroll Committed by Dridi Boukelmoune

promote resp.body / beresp.body syntax a bit more

Should we plan to phase out synthetic() ?
parent 5cde1b15
...@@ -9,7 +9,7 @@ varnish v1 -vcl { ...@@ -9,7 +9,7 @@ varnish v1 -vcl {
} }
sub vcl_synth { sub vcl_synth {
synthetic("Custom vcl_synth's synth output"); set resp.body = "Custom vcl_synth's body";
return (deliver); return (deliver);
} }
} -start } -start
...@@ -18,8 +18,9 @@ client c1 { ...@@ -18,8 +18,9 @@ client c1 {
txreq -url "/" txreq -url "/"
rxresp rxresp
expect resp.status == 888 expect resp.status == 888
expect resp.bodylen == 31
expect resp.http.connection != close expect resp.http.connection != close
expect resp.bodylen == 23
expect resp.body == "Custom vcl_synth's body"
} -run } -run
varnish v1 -expect s_synth == 1 varnish v1 -expect s_synth == 1
...@@ -8,7 +8,7 @@ varnish v1 -vcl { ...@@ -8,7 +8,7 @@ varnish v1 -vcl {
set beresp.ttl = 1s; set beresp.ttl = 1s;
set beresp.grace = 3s; set beresp.grace = 3s;
set beresp.http.foobar = "BLA" + bereq.xid; set beresp.http.foobar = "BLA" + bereq.xid;
synthetic(beresp.http.foobar); set beresp.body = beresp.http.foobar;
return (deliver); return (deliver);
} }
} -start } -start
...@@ -24,9 +24,11 @@ client c1 { ...@@ -24,9 +24,11 @@ client c1 {
txreq txreq
rxresp rxresp
expect resp.http.foobar == "BLA1002" expect resp.http.foobar == "BLA1002"
expect resp.body == "BLA1002"
delay 3 delay 3
txreq txreq
rxresp rxresp
expect resp.http.foobar == "BLA1004" expect resp.http.foobar == "BLA1004"
expect resp.body == "BLA1004"
} -run } -run
...@@ -37,7 +37,7 @@ varnish v1 -vcl+backend { ...@@ -37,7 +37,7 @@ varnish v1 -vcl+backend {
return (restart); return (restart);
} else { } else {
set resp.http.restarts = req.restarts; set resp.http.restarts = req.restarts;
synthetic(req.restarts); set resp.body = req.restarts;
} }
} }
return (deliver); return (deliver);
......
...@@ -42,8 +42,8 @@ varnish v1 -vcl+backend { ...@@ -42,8 +42,8 @@ varnish v1 -vcl+backend {
} }
sub vcl_synth { sub vcl_synth {
synthetic("Response was served by " set resp.body = "Response was served by "
+ std.fileread("${tmpdir}/m00004_file_four")); + std.fileread("${tmpdir}/m00004_file_four");
return(deliver); return(deliver);
} }
} -start } -start
...@@ -111,8 +111,8 @@ varnish v1 -vcl+backend { ...@@ -111,8 +111,8 @@ varnish v1 -vcl+backend {
} }
sub vcl_synth { sub vcl_synth {
synthetic("Response was served by " set resp.body = "Response was served by "
+ std.fileread("${tmpdir}/m00004_file_four")); + std.fileread("${tmpdir}/m00004_file_four");
return(deliver); return(deliver);
} }
} }
......
...@@ -18,7 +18,8 @@ varnish v1 -vcl+backend { ...@@ -18,7 +18,8 @@ varnish v1 -vcl+backend {
sub vcl_synth { sub vcl_synth {
if (resp.status == 998) { if (resp.status == 998) {
synthetic("this is the body of an included synthetic response"); set resp.body = "this is the body of an " +
"included synthetic response";
return(deliver); return(deliver);
} }
} }
......
...@@ -14,7 +14,7 @@ varnish v1 -vcl+backend { ...@@ -14,7 +14,7 @@ varnish v1 -vcl+backend {
sub vcl_synth { sub vcl_synth {
if (resp.status == 998) { if (resp.status == 998) {
synthetic("synthetic body"); set resp.body = "synthetic body";
return (deliver); return (deliver);
} }
} }
......
...@@ -6,7 +6,7 @@ server s1 { ...@@ -6,7 +6,7 @@ server s1 {
varnish v1 -arg "-s Transient=file,${tmpdir}/_.file,10m" -vcl+backend { varnish v1 -arg "-s Transient=file,${tmpdir}/_.file,10m" -vcl+backend {
sub vcl_backend_error { sub vcl_backend_error {
synthetic("foo"); set beresp.body = "foo";
return (deliver); return (deliver);
} }
} -start } -start
......
...@@ -467,8 +467,10 @@ hash_data(input) ...@@ -467,8 +467,10 @@ hash_data(input)
synthetic(STRING) synthetic(STRING)
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
Prepare a synthetic response body containing the *STRING*. Available in Prepare a synthetic response body containing the *STRING*. Available
``vcl_synth`` and ``vcl_backend_error``. in ``vcl_synth`` and ``vcl_backend_error``.
Identical to ``set resp.body`` / ``set beresp.body``.
.. list above comes from struct action_table[] in vcc_action.c. .. list above comes from struct action_table[] in vcc_action.c.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment