Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
If the backend sends content-length header and streaming does
Browse files Browse the repository at this point in the history
not gunzip, send content-length to client rather than chunked.

This makes progress-bars possible in browsers.
  • Loading branch information
bsdphk committed May 9, 2011
1 parent 4e7def9 commit 4f17a11
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/varnishd/cache_center.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions bin/varnishd/cache_response.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions bin/varnishtest/tests/t00001.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4f17a11

Please sign in to comment.