From 2ea39777fc9faafc767a40382ed2a2ca48e35418 Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 26 Oct 2007 11:13:32 +0000 Subject: [PATCH] Don't mess up the chunked encoding for nested esi:include git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2172 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_response.c | 17 +++++++++-------- varnish-cache/bin/varnishd/cache_vrt_esi.c | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_response.c b/varnish-cache/bin/varnishd/cache_response.c index 33eaea50..2633f76a 100644 --- a/varnish-cache/bin/varnishd/cache_response.c +++ b/varnish-cache/bin/varnishd/cache_response.c @@ -152,20 +152,21 @@ RES_WriteObj(struct sess *sp) unsigned u = 0; char lenbuf[20]; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); WRK_Reset(sp->wrk, &sp->fd); - if (sp->esis == 0) { + if (sp->esis == 0) sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1); - } else { - sprintf(lenbuf, "%x\r\n", sp->obj->len); - sp->wrk->acct.hdrbytes += WRK_Write(sp->wrk, lenbuf, -1); - } - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); if (sp->wantbody && !VTAILQ_EMPTY(&sp->obj->esibits)) { ESI_Deliver(sp); } else if (sp->wantbody) { + if (sp->esis > 0) { + sprintf(lenbuf, "%x\r\n", sp->obj->len); + sp->wrk->acct.hdrbytes += + WRK_Write(sp->wrk, lenbuf, -1); + } VTAILQ_FOREACH(st, &sp->obj->store, list) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); @@ -191,9 +192,9 @@ RES_WriteObj(struct sess *sp) WRK_Write(sp->wrk, st->ptr, st->len); } assert(u == sp->obj->len); + if (sp->esis > 0) + WRK_Write(sp->wrk, "\r\n", -1); } - if (sp->esis > 0) - WRK_Write(sp->wrk, "\r\n", -1); if (WRK_Flush(sp->wrk)) vca_close_session(sp, "remote closed"); } diff --git a/varnish-cache/bin/varnishd/cache_vrt_esi.c b/varnish-cache/bin/varnishd/cache_vrt_esi.c index 806e1c51..363b0c9a 100644 --- a/varnish-cache/bin/varnishd/cache_vrt_esi.c +++ b/varnish-cache/bin/varnishd/cache_vrt_esi.c @@ -605,7 +605,8 @@ ESI_Deliver(struct sess *sp) sp->obj = obj; } - WRK_Write(sp->wrk, "0\r\n", -1); + if (sp->esis == 0) + WRK_Write(sp->wrk, "0\r\n", -1); } /*--------------------------------------------------------------------*/ -- 2.39.5