[master] 4f17a11 If the backend sends content-length header and streaming does not gunzip, send content-length to client rather than chunked.
Poul-Henning Kamp
phk at varnish-cache.org
Mon May 9 11:30:20 CEST 2011
commit 4f17a11950fc0e4e66e1997ebb9768317175b8b6
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon May 9 09:29:31 2011 +0000
If the backend sends content-length header and streaming does
not gunzip, send content-length to client rather than chunked.
This makes progress-bars possible in browsers.
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index edfe75d..d6101e1 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -166,7 +166,8 @@ cnt_prepresp(struct sess *sp)
sp->wrk->res_mode = 0;
- if (!sp->wrk->do_stream)
+ if (!sp->wrk->do_stream ||
+ (sp->wrk->h_content_length != NULL && !sp->wrk->do_gunzip))
sp->wrk->res_mode |= RES_LEN;
if (!sp->disable_esi && sp->obj->esidata != NULL) {
diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c
index 9ffb95e..509954d 100644
--- a/bin/varnishd/cache_response.c
+++ b/bin/varnishd/cache_response.c
@@ -410,6 +410,11 @@ RES_StreamStart(struct sess *sp)
if (sp->wrk->res_mode & RES_GUNZIP)
http_Unset(sp->wrk->resp, H_Content_Encoding);
+ if (!(sp->wrk->res_mode & RES_CHUNKED) &&
+ sp->wrk->h_content_length != NULL)
+ http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp,
+ "Content-Length: %s", sp->wrk->h_content_length);
+
sp->acct_tmp.hdrbytes +=
http_Write(sp->wrk, sp->wrk->resp, 1);
diff --git a/bin/varnishtest/tests/t00001.vtc b/bin/varnishtest/tests/t00001.vtc
index 5fefc70..2237466 100644
--- a/bin/varnishtest/tests/t00001.vtc
+++ b/bin/varnishtest/tests/t00001.vtc
@@ -36,6 +36,7 @@ varnish v1 -vcl+backend {
client c1 {
txreq -url /bar
rxresp
+ expect resp.http.content-length == 6
expect resp.bodylen == 6
txreq -url /bla
rxresp
More information about the varnish-commit
mailing list