[master] 8b1f899 Make ESI delivery less magic.
Poul-Henning Kamp
phk at FreeBSD.org
Thu May 14 19:16:02 CEST 2015
commit 8b1f8991a3d54c7f1cd39f7995bfb1d00f80753f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu May 14 17:15:24 2015 +0000
Make ESI delivery less magic.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 2f0d228..17f59dd 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -684,7 +684,7 @@ struct sess {
* or may not, be talking a "real" HTTP protocol itself.
*/
-typedef void vtr_deliver_f (struct req *);
+typedef void vtr_deliver_f (struct req *, struct busyobj *);
struct transport {
unsigned magic;
@@ -746,7 +746,7 @@ extern const int HTTP1_Req[3];
extern const int HTTP1_Resp[3];
/* cache_http1_deliver.c */
-void V1D_Deliver(struct req *);
+vtr_deliver_f V1D_Deliver;
/* cache_http1_pipe.c */
void V1P_Init(void);
@@ -1113,8 +1113,6 @@ char *VRT_StringList(char *d, unsigned dl, const char *p, va_list ap);
void VRTPRIV_init(struct vrt_privs *privs);
void VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id);
-int VED_Setup(struct req *req, struct busyobj *bo);
-
/* cache_vrt_vmod.c */
void VMOD_Init(void);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 087af87..356d0ea 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -41,6 +41,8 @@
#include "vend.h"
#include "vgz.h"
+static vtr_deliver_f VED_Deliver;
+
/*--------------------------------------------------------------------*/
static int __match_proto__(vdp_bytes)
@@ -108,10 +110,18 @@ ved_include(struct req *preq, const char *src, const char *host)
http_ForceField(req->http0, HTTP_HDR_METHOD, "GET");
http_ForceField(req->http0, HTTP_HDR_PROTO, "HTTP/1.1");
- /* Don't allow Conditions, we can't use a 304 */
+ /* Don't allow conditionalss, we can't use a 304 */
http_Unset(req->http0, H_If_Modified_Since);
http_Unset(req->http0, H_If_None_Match);
+ /* Don't allow Range */
+ http_Unset(req->http0, H_Range);
+
+ /* Set Accept-Encoding according to what we want */
+ http_Unset(req->http0, H_Accept_Encoding);
+ if (preq->gzip_resp)
+ http_ForceHeader(req->http0, H_Accept_Encoding, "gzip");
+
/* Client content already taken care of */
http_Unset(req->http0, H_Content_Length);
@@ -136,6 +146,7 @@ ved_include(struct req *preq, const char *src, const char *host)
req->l_crc = preq->l_crc;
INIT_OBJ(&xp, TRANSPORT_MAGIC);
+ xp.deliver = VED_Deliver;
req->transport = &xp;
req->transport_priv = preq;
@@ -656,50 +667,33 @@ ved_stripgzip(struct req *req)
req->l_crc += ilen;
}
-int
-VED_Setup(struct req *req, struct busyobj *bo)
+static void __match_proto__(vtr_deliver_f)
+VED_Deliver(struct req *req, struct busyobj *bo)
{
int i;
struct req *preq;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+ CHECK_OBJ_ORNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
- /*
- * Determine ESI status first. Not dependent on wantbody, because
- * we want ESI to supress C-L in HEAD too.
- */
- if (!req->disable_esi &&
- ObjGetattr(req->wrk, req->objcore, OA_ESIDATA, NULL) != NULL) {
- req->res_mode |= RES_ESI;
- RFC2616_Weaken_Etag(req->resp);
- req->resp_len = -1;
- VDP_push(req, VDP_ESI, NULL, 0);
- }
-
- /* ESI-childen need special treatment */
- if (req->esi_level == 0)
- return (0);
-
CAST_OBJ_NOTNULL(preq, req->transport_priv, REQ_MAGIC);
- VDP_push(req, ved_vdp_bytes, preq, 1);
-
req->res_mode |= RES_ESI_CHILD;
i = ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED);
if (req->gzip_resp && i && !(req->res_mode & RES_ESI)) {
+ VDP_push(req, ved_vdp_bytes, preq, 1);
+
if (bo != NULL)
VBO_waitstate(bo, BOS_FINISHED);
ved_stripgzip(req);
(void)VDP_bytes(req, VDP_FLUSH, NULL, 0);
} else {
if (req->gzip_resp && !i)
- VDP_push(req, ved_pretend_gzip, NULL, 0);
- else if (!req->gzip_resp && i)
- VDP_push(req, VDP_gunzip, NULL, 0);
+ VDP_push(req, ved_pretend_gzip, NULL, 1);
+ VDP_push(req, ved_vdp_bytes, preq, 1);
(void)VDP_DeliverObj(req);
}
VDP_close(req);
- return (1);
}
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 8f0f1a4..1f0e306 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -58,8 +58,18 @@ cnt_vdp(struct req *req, struct busyobj *bo)
else
req->resp_len = ObjGetLen(req->wrk, req->objcore);
- if (VED_Setup(req, bo))
- return;
+ /*
+ * Determine ESI status first. Not dependent on wantbody, because
+ * we want ESI to supress C-L in HEAD too.
+ */
+ if (!req->disable_esi &&
+ ObjGetattr(req->wrk, req->objcore, OA_ESIDATA, NULL) != NULL) {
+ req->res_mode |= RES_ESI;
+ RFC2616_Weaken_Etag(req->resp);
+ req->resp_len = -1;
+ VDP_push(req, VDP_ESI, NULL, 0);
+ }
+
if (cache_param->http_gzip_support &&
ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) &&
@@ -81,7 +91,7 @@ cnt_vdp(struct req *req, struct busyobj *bo)
}
CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC);
- req->transport->deliver(req);
+ req->transport->deliver(req, bo);
}
/*--------------------------------------------------------------------
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index 221173d..710dee2 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -61,11 +61,12 @@ v1d_bytes(struct req *req, enum vdp_action act, void **priv,
*/
void __match_proto__(vtr_deliver_f)
-V1D_Deliver(struct req *req)
+V1D_Deliver(struct req *req, struct busyobj *bo)
{
enum objiter_status ois;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+ CHECK_OBJ_ORNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
if ((req->objcore->flags & OC_F_PRIVATE) &&
More information about the varnish-commit
mailing list