[master] 93820a1 Implement a resp.is_streaming status variable
Martin Blix Grydeland
martin at varnish-software.com
Tue May 5 12:57:39 CEST 2015
commit 93820a16c0d50c4e0b00e4d570eb4478873b4918
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Tue May 5 11:49:32 2015 +0200
Implement a resp.is_streaming status variable
This variable will be true when the response object's body will be
streamed from the backend.
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index e900726..5ae624e 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -658,6 +658,19 @@ VRT_r_obj_uncacheable(VRT_CTX)
/*--------------------------------------------------------------------*/
+unsigned
+VRT_r_resp_is_streaming(VRT_CTX)
+{
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
+ if (ctx->req->objcore == NULL)
+ return (0); /* When called from vcl_synth */
+ CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
+ return (ctx->req->objcore->busyobj != NULL ? 1 : 0);
+}
+
+/*--------------------------------------------------------------------*/
+
#define HTTP_VAR(x) \
struct http * \
VRT_r_##x(VRT_CTX) \
diff --git a/bin/varnishtest/tests/c00069.vtc b/bin/varnishtest/tests/c00069.vtc
new file mode 100644
index 0000000..fc41422
--- /dev/null
+++ b/bin/varnishtest/tests/c00069.vtc
@@ -0,0 +1,39 @@
+varnishtest "Test resp.is_streaming"
+
+server s1 {
+ rxreq
+ txresp -nolen -hdr "Content-Length: 10"
+ delay 1
+ send "1234567890"
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_recv {
+ if (req.url == "/synth") {
+ return(synth(200, "OK"));
+ }
+ }
+ sub vcl_synth {
+ set resp.http.streaming = resp.is_streaming;
+ }
+ sub vcl_deliver {
+ set resp.http.streaming = resp.is_streaming;
+ }
+} -start
+
+client c1 {
+ txreq
+ rxresp
+ expect resp.http.streaming == "true"
+
+ delay 0.1
+
+ txreq
+ rxresp
+ expect resp.http.streaming == "false"
+
+ txreq -url /synth
+ rxresp
+ expect resp.http.streaming == "false"
+} -run
+
diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py
index 2c1226f..c541e8f 100755
--- a/lib/libvcc/generate.py
+++ b/lib/libvcc/generate.py
@@ -670,6 +670,14 @@ sp_variables = [
The corresponding HTTP header.
"""
),
+ ('resp.is_streaming',
+ 'BOOL',
+ ( 'deliver', 'synth', ),
+ ( ), """
+ Returns true when the response will be streamed
+ from the backend.
+ """
+ ),
('now',
'TIME',
( 'all',),
More information about the varnish-commit
mailing list