r2185 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Mon Oct 29 11:20:43 CET 2007
Author: phk
Date: 2007-10-29 11:20:36 +0100 (Mon, 29 Oct 2007)
New Revision: 2185
Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
Log:
Implement relative URL for esi:include. Use the bereq.url as
starting point, since req.url may have been rewritten underway.
Store result in objects workspace.
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-29 10:17:58 UTC (rev 2184)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-29 10:20:36 UTC (rev 2185)
@@ -261,6 +261,8 @@
char *p, *q;
txt tag;
txt val;
+ unsigned u, v;
+ struct ws *ws;
VSL(SLT_Debug, 0, "Incl \"%.*s\"", t.e - t.b, t.b);
eb = esi_addbit(ew);
@@ -290,11 +292,40 @@
/* Absolute on this host */
eb->include = val;
} else {
- /* Relative to current URL */
- /* XXX: search forward to '?' use previous / */
- /* XXX: where to store edited result ? */
- eb->include = val;
- INCOMPL();
+
+ /*
+ * Decision: We interpret the relative URL against
+ * the actual URL we asked the backend for.
+ * The client's request URL may be entirely
+ * different and have been rewritten underway.
+ */
+ CHECK_OBJ_NOTNULL(ew->sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(ew->sp->bereq, BEREQ_MAGIC);
+ CHECK_OBJ_NOTNULL(ew->sp->bereq->http, HTTP_MAGIC);
+ tag = ew->sp->bereq->http->hd[HTTP_HDR_URL];
+
+ /* Use the objects WS to store the result */
+ CHECK_OBJ_NOTNULL(ew->sp->obj, OBJECT_MAGIC);
+ ws = ew->sp->obj->ws_o;
+ WS_Assert(ws);
+
+ /* Look for the last '/' before a '?' */
+ q = NULL;
+ for (p = tag.b; p < tag.e && *p != '?'; p++)
+ if (*p == '/')
+ q = p;
+ if (q != NULL)
+ tag.e = q + 1;
+
+ u = WS_Reserve(ws, 0);
+ v = snprintf(ws->f, u - 1, "%.*s%.*s",
+ tag.e - tag.b, tag.b,
+ val.e - val.b, val.b);
+ v++;
+ xxxassert(v < u);
+ eb->include.b = ws->f;
+ eb->include.e = ws->f + v;
+ WS_Release(ws, v);
}
}
}
More information about the varnish-commit
mailing list