Commit df1cdb82 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Avoid duplicate Begin/End records on ESI subrequests

When starting an ESI subrequest, make sure that the Begin/End headers
are only output once, formatted for ESI.

Fixes: #1441
parent 2386b351
......@@ -61,6 +61,7 @@ ved_include(struct req *preq, const char *src, const char *host)
req = SES_GetReq(wrk, preq->sp);
req->req_body_status = REQ_BODY_NONE;
AN(req->vsl->wid & VSL_CLIENTMARKER);
VSLb(req->vsl, SLT_Begin, "req %u esi", preq->vsl->wid & VSL_IDENTMASK);
VSLb(preq->vsl, SLT_Link, "req %u esi", req->vsl->wid & VSL_IDENTMASK);
req->esi_level = preq->esi_level + 1;
......@@ -115,8 +116,8 @@ ved_include(struct req *preq, const char *src, const char *host)
(void)usleep(10000);
}
VSLb(req->vsl, SLT_End, "%s", "");
req->vsl->wid = 0;
/* Make sure the VSL id has been released */
AZ(req->vsl->wid);
/* Reset the workspace */
WS_Reset(wrk->aws, wrk_ws_wm); /* XXX ? */
......
......@@ -159,6 +159,9 @@ ses_sess_pool_task(struct worker *wrk, void *arg)
req = SES_GetReq(wrk, sp);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
AN(req->vsl->wid & VSL_CLIENTMARKER);
VSLb(req->vsl, SLT_Begin, "req %u rxreq", sp->vxid & VSL_IDENTMASK);
VSL(SLT_Link, sp->vxid, "req %u rxreq", req->vsl->wid & VSL_IDENTMASK);
sp->sess_step = S_STP_NEWREQ;
ses_req_pool_task(wrk, req);
......@@ -389,9 +392,6 @@ SES_GetReq(struct worker *wrk, struct sess *sp)
sz = cache_param->vsl_buffer;
VSL_Setup(req->vsl, p, sz);
req->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER;
VSLb(req->vsl, SLT_Begin, "req %u rxreq", sp->vxid & VSL_IDENTMASK);
VSL(SLT_Link, req->sp->vxid, "req %u rxreq",
req->vsl->wid & VSL_IDENTMASK);
p += sz;
p = (void*)PRNDUP(p);
......
varnishtest "Session grouping on ESI"
server s1 {
rxreq
expect req.url == "/"
txresp -body "<esi:include src=\"/include\"/>"
rxreq
expect req.url == "/include"
txresp -body "included"
} -start
varnish v1 -vcl+backend {
sub vcl_backend_response {
if (bereq.url == "/") {
set beresp.do_esi = true;
}
}
} -start
logexpect l1 -v v1 -g session {
expect 0 1000 Begin sess 0 HTTP/1
expect * = End
expect 0 1001 Begin req 1000 rxreq
expect * = End
expect 0 1002 Begin bereq 1001 fetch
expect * = End
expect 0 1003 Begin req 1001 esi
expect * = End
expect 0 1004 Begin bereq 1003 fetch
expect * = End
} -start
client c1 {
txreq -url "/"
rxresp
expect resp.status == 200
} -run
logexpect l1 -wait
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