Commit 93820a16 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Implement a resp.is_streaming status variable

This variable will be true when the response object's body will be
streamed from the backend.
parent 18a06da3
......@@ -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) \
......
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
......@@ -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',),
......
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