commit a7672475cbec59b3c3d2afe4f551468f662da43e
Author: Martin Blix Grydeland <martin@varnish-software.com>
Date:   Thu Aug 4 21:31:57 2011 +0200

    Don't attempt conditional delivery when we are doing streaming, as we
    are already commited to streaming the object.
    
    Problem spotted by DocWilco.
    
    Fixes: #972

diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c
index 4788a23..e36c289 100644
--- a/bin/varnishd/cache_response.c
+++ b/bin/varnishd/cache_response.c
@@ -95,6 +95,9 @@ res_do_conds(struct sess *sp)
 	/* RFC 2616 13.3.4 states we need to match both ETag
 	   and If-Modified-Since if present*/
 
+	if (sp->wrk->do_stream)
+		return (0);
+
 	if (http_GetHdr(sp->http, H_If_Modified_Since, &p) ) {
 		if (!sp->obj->last_modified)
 			return (0);
diff --git a/bin/varnishtest/tests/r00972.vtc b/bin/varnishtest/tests/r00972.vtc
new file mode 100644
index 0000000..0f2e7cc
--- /dev/null
+++ b/bin/varnishtest/tests/r00972.vtc
@@ -0,0 +1,20 @@
+varnishtest "Test conditional delivery and do_stream"
+
+server s1 {
+	rxreq
+	txresp -hdr "ETag: foo" -body "11111\n"
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_fetch {
+		set beresp.do_stream = true;
+	}
+} -start
+
+client c1 {
+	txreq -hdr "If-None-Match: foo"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.etag == "foo"
+	expect resp.bodylen == 6
+}  -run
