Commit 58f45b4f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

For ESI responses we can only use Chunked encoding for HTTP/1.1 and

later.  Use EOF-encoding for sessions where the request is lower
HTTP protocol versions.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3292 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 9e4e9395
......@@ -105,6 +105,10 @@ RES_BuildHttp(struct sess *sp)
http_FilterFields(sp->wrk, sp->fd, sp->http, sp->obj->http,
HTTPH_A_DELIVER);
/* Only HTTP 1.1 can do Chunked encoding */
if (sp->http->protover < 1.1 && !VTAILQ_EMPTY(&sp->obj->esibits))
http_Unset(sp->http, H_Transfer_Encoding);
TIM_format(TIM_real(), time_str);
http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Date: %s", time_str);
......@@ -140,7 +144,7 @@ RES_WriteObj(struct sess *sp)
if (sp->wantbody && !VTAILQ_EMPTY(&sp->obj->esibits)) {
ESI_Deliver(sp);
} else if (sp->wantbody) {
if (sp->esis > 0) {
if (sp->esis > 0 && sp->http->protover >= 1.1) {
sprintf(lenbuf, "%x\r\n", sp->obj->len);
sp->wrk->acct.hdrbytes +=
WRK_Write(sp->wrk, lenbuf, -1);
......@@ -170,7 +174,7 @@ RES_WriteObj(struct sess *sp)
WRK_Write(sp->wrk, st->ptr, st->len);
}
assert(u == sp->obj->len);
if (sp->esis > 0)
if (sp->esis > 0 && sp->http->protover >= 1.1)
WRK_Write(sp->wrk, "\r\n", -1);
}
if (WRK_Flush(sp->wrk))
......
......@@ -802,9 +802,11 @@ ESI_Deliver(struct sess *sp)
VTAILQ_FOREACH(eb, &sp->obj->esibits, list) {
if (Tlen(eb->verbatim)) {
WRK_Write(sp->wrk, eb->chunk_length, -1);
if (sp->http->protover >= 1.1)
WRK_Write(sp->wrk, eb->chunk_length, -1);
WRK_Write(sp->wrk, eb->verbatim.b, Tlen(eb->verbatim));
WRK_Write(sp->wrk, "\r\n", -1);
if (sp->http->protover >= 1.1)
WRK_Write(sp->wrk, "\r\n", -1);
}
if (eb->include.b == NULL ||
sp->esis >= params->max_esi_includes)
......@@ -842,7 +844,7 @@ ESI_Deliver(struct sess *sp)
sp->obj = obj;
}
if (sp->esis == 0)
if (sp->esis == 0 && sp->http->protover >= 1.1)
WRK_Write(sp->wrk, "0\r\n\r\n", -1);
}
......
# $Id$
test "ESI includes for pre HTTP/1.1 cannot used chunked encoding"
server s1 {
rxreq
expect req.url == "/foo/bar"
txresp -body {
<html>
Before include
<!--esi <esi:include src="body"/> -->
After include
}
rxreq
expect req.url == "/foo/body"
txresp -body {
Included file
}
} -start
varnish v1 -vcl+backend {
sub vcl_fetch {
esi;
}
} -start
client c1 {
txreq -url /foo/bar -proto HTTP/1.1
rxresp
expect resp.status == 200
expect resp.bodylen == 151
} -run
client c1 {
txreq -url /foo/bar -proto HTTP/1.0
rxresp
expect resp.status == 200
expect resp.bodylen == 151
} -run
client c1 {
txreq -url /foo/bar -proto ""
rxresp
expect resp.status == 200
expect resp.bodylen == 151
} -run
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