Created
December 6, 2010 17:15
-
-
Save unicornrainbow/730589 to your computer and use it in GitHub Desktop.
Add req.esis to vcl in varnish 2.1.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/bin/varnishd/cache_vrt.c b/bin/varnishd/cache_vrt.c | |
index dc855c9..48aa2ea 100644 | |
--- a/bin/varnishd/cache_vrt.c | |
+++ b/bin/varnishd/cache_vrt.c | |
@@ -664,6 +664,15 @@ VRT_r_req_esi(struct sess *sp) | |
/*--------------------------------------------------------------------*/ | |
int | |
+VRT_r_req_esis(const struct sess *sp) | |
+{ | |
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); | |
+ return (sp->esis); | |
+} | |
+ | |
+/*--------------------------------------------------------------------*/ | |
+ | |
+int | |
VRT_r_req_restarts(const struct sess *sp) | |
{ | |
diff --git a/bin/varnishtest/tests/e00019.vtc b/bin/varnishtest/tests/e00019.vtc | |
new file mode 100644 | |
index 0000000..0ef8cba | |
--- /dev/null | |
+++ b/bin/varnishtest/tests/e00019.vtc | |
@@ -0,0 +1,48 @@ | |
+# $Id: e00018.vtc 4554 2010-02-12 11:25:46Z phk $ | |
+ | |
+test "Test req.esis" | |
+ | |
+server s1 { | |
+ rxreq | |
+ expect req.http.X-Esis == 0 | |
+ txresp -body { | |
+ <html> | |
+ <esi:include src="/body1"/> | |
+ <esi:include src="/body2"/> | |
+ } | |
+ | |
+ rxreq | |
+ expect req.http.X-Esis == 1 | |
+ expect req.url == "/body1" | |
+ txresp -body { | |
+ <html> | |
+ <esi:include src="/body11"/> | |
+ } | |
+ | |
+ rxreq | |
+ expect req.http.X-Esis == 2 | |
+ expect req.url == "/body11" | |
+ txresp -body "11" | |
+ | |
+ rxreq | |
+ expect req.http.X-Esis == 1 | |
+ expect req.url == "/body2" | |
+ txresp -body "2" | |
+} -start | |
+ | |
+varnish v1 -vcl+backend { | |
+ sub vcl_recv { | |
+ set req.http.X-Esis = req.esis; | |
+ return (pass); | |
+ } | |
+ sub vcl_fetch { | |
+ esi; | |
+ } | |
+} -start | |
+ | |
+client c1 { | |
+ txreq | |
+ rxresp | |
+ expect resp.status == 200 | |
+ expect resp.bodylen == 34 | |
+} -run | |
diff --git a/lib/libvcl/vcc_gen_fixed_token.tcl b/lib/libvcl/vcc_gen_fixed_token.tcl | |
index d34a9ee..64eae21 100755 | |
--- a/lib/libvcl/vcc_gen_fixed_token.tcl | |
+++ b/lib/libvcl/vcc_gen_fixed_token.tcl | |
@@ -173,6 +173,12 @@ set spobj { | |
"struct sess *" | |
} | |
+ { req.esis INT | |
+ RO | |
+ all | |
+ "const struct sess *" | |
+ } | |
+ | |
{ req.backend.healthy BOOL | |
RO | |
all | |
diff --git a/man/vcl.7 b/man/vcl.7 | |
index e867ed0..dafea8f 100644 | |
--- a/man/vcl.7 | |
+++ b/man/vcl.7 | |
@@ -655,6 +655,10 @@ Force a cache miss for this request. | |
.B req.hash_ignore_busy | |
. | |
Ignore any busy object during cache lookup. | |
+.TP | |
+.B req.esis | |
+. | |
+The ESI nesting level of the request. | |
.UNINDENT | |
.sp | |
The following variables are available while preparing a backend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment