[master] 275800f Implement resp.do_esi

Poul-Henning Kamp phk at FreeBSD.org
Fri Feb 23 21:44:08 UTC 2018


commit 275800fdce33d13763ce0eb014e48db68ca5d8c3
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Feb 23 21:42:02 2018 +0000

    Implement resp.do_esi

diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 2ab2fdb..1b071c9 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -454,6 +454,7 @@ VRT_l_req_esi(VRT_CTX, unsigned process_esi)
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
+	assert(ctx->syntax <= 40);
 	/*
 	 * Only allow you to turn of esi in the main request
 	 * else everything gets confused
@@ -468,6 +469,7 @@ VRT_r_req_esi(VRT_CTX)
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
+	assert(ctx->syntax <= 40);
 	return (!ctx->req->disable_esi);
 }
 
@@ -728,6 +730,32 @@ VRT_r_resp_is_streaming(VRT_CTX)
 
 /*--------------------------------------------------------------------*/
 
+void
+VRT_l_resp_do_esi(VRT_CTX, unsigned process_esi)
+{
+
+	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
+	assert(ctx->syntax >= 41);
+	/*
+	 * Only allow you to turn of esi in the main request
+	 * else everything gets confused
+	 */
+	ctx->req->disable_esi = !process_esi;
+}
+
+unsigned
+VRT_r_resp_do_esi(VRT_CTX)
+{
+
+	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
+	assert(ctx->syntax >= 41);
+	return (!ctx->req->disable_esi);
+}
+
+/*--------------------------------------------------------------------*/
+
 #define VRT_BODY_L(which)					\
 void								\
 VRT_l_##which##_body(VRT_CTX, const char *str, ...)		\
diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst
index 9631ed3..3d17078 100644
--- a/doc/sphinx/reference/vcl_var.rst
+++ b/doc/sphinx/reference/vcl_var.rst
@@ -1065,6 +1065,20 @@ resp.http.*
 
 	
 	The HTTP headers that will be returned.
+
+resp.do_esi	``VCL >= 4.1``
+
+	Type: BOOL
+
+	Readable from: vcl_deliver, vcl_synth
+
+	Writable from: vcl_deliver, vcl_synth
+
+	Default: Set if ESI parsing has happened.
+
+	This can be used to selectively disable ESI processing,
+	even though ESI parsing happened during fetch.
+	This is useful when Varnish caches peer with each other.
 	
 
 resp.is_streaming


More information about the varnish-commit mailing list