Commit 7333dde2 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Pull the protocol-agnostic bits of VDP (esi, range, gunzip) out of V1D

and plunk it down in req_fsm for now.
parent b86ffb93
......@@ -741,7 +741,7 @@ extern const int HTTP1_Req[3];
extern const int HTTP1_Resp[3];
/* cache_http1_deliver.c */
void V1D_Deliver(struct req *, struct busyobj *);
void V1D_Deliver(struct req *);
/* cache_http1_pipe.c */
void V1P_Init(void);
......@@ -1107,7 +1107,7 @@ 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);
void ESI_DeliverChild(struct req *, struct busyobj *);
int VED_Setup(struct req *req, struct busyobj *bo);
/* cache_vrt_vmod.c */
void VMOD_Init(void);
......
......@@ -653,11 +653,30 @@ ved_stripgzip(struct req *req)
req->l_crc += ilen;
}
void
ESI_DeliverChild(struct req *req, struct busyobj *bo)
int
VED_Setup(struct req *req, struct busyobj *bo)
{
int i;
CHECK_OBJ_NOTNULL(req, REQ_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);
req->res_mode |= RES_ESI_CHILD;
i = ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED);
if (req->gzip_resp && i && !(req->res_mode & RES_ESI)) {
......@@ -666,8 +685,6 @@ ESI_DeliverChild(struct req *req, struct busyobj *bo)
ved_stripgzip(req);
(void)VDP_bytes(req, VDP_FLUSH, NULL, 0);
} else {
if (req->res_mode & RES_ESI)
VDP_push(req, VDP_ESI, NULL, 0);
if (req->gzip_resp && !i)
VDP_push(req, ved_pretend_gzip, NULL, 0);
else if (!req->gzip_resp && i)
......@@ -676,4 +693,5 @@ ESI_DeliverChild(struct req *req, struct busyobj *bo)
(void)VDP_DeliverObj(req);
}
VDP_close(req);
return (1);
}
......@@ -40,12 +40,49 @@
#include "cache.h"
#include "cache_director.h"
#include "cache_filter.h"
#include "hash/hash_slinger.h"
#include "vcl.h"
#include "vsha256.h"
#include "vtim.h"
static void
cnt_vdp(struct req *req, struct busyobj *bo)
{
const char *r;
req->res_mode = 0;
if (bo != NULL)
req->resp_len = http_GetContentLength(bo->beresp);
else
req->resp_len = ObjGetLen(req->wrk, req->objcore);
if (VED_Setup(req, bo))
return;
if (cache_param->http_gzip_support &&
ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) &&
!RFC2616_Req_Gzip(req->http)) {
req->res_mode |= RES_GUNZIP;
VDP_push(req, VDP_gunzip, NULL, 1);
}
/*
* Range comes after the others and pushes on bottom because
* it can generate a correct C-L header.
*/
if (cache_param->http_range_support &&
http_IsStatus(req->resp, 200)) {
http_SetHeader(req->resp, "Accept-Ranges: bytes");
if (req->wantbody &&
http_GetHdr(req->http, H_Range, &r))
VRG_dorange(req, r);
}
V1D_Deliver(req);
}
/*--------------------------------------------------------------------
* Deliver an object to client
*/
......@@ -144,7 +181,9 @@ cnt_deliver(struct worker *wrk, struct req *req)
VBO_DerefBusyObj(wrk, &bo);
}
}
V1D_Deliver(req, bo);
cnt_vdp(req, bo);
if (bo != NULL)
VBO_DerefBusyObj(wrk, &bo);
......@@ -235,7 +274,7 @@ cnt_synth(struct worker *wrk, struct req *req)
VSB_delete(req->synth_body);
req->synth_body = NULL;
V1D_Deliver(req, NULL);
cnt_vdp(req, NULL);
(void)HSH_DerefObjCore(wrk, &req->objcore);
}
......
......@@ -61,67 +61,13 @@ v1d_bytes(struct req *req, enum vdp_action act, void **priv,
*/
void
V1D_Deliver(struct req *req, struct busyobj *bo)
V1D_Deliver(struct req *req)
{
const char *r;
enum objiter_status ois;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
req->res_mode = 0;
if (bo != NULL)
req->resp_len = http_GetContentLength(bo->beresp);
else
req->resp_len = ObjGetLen(req->wrk, req->objcore);
/*
* 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;
/*
* ESI-childen don't care about headers -> early escape
*/
if (req->esi_level > 0) {
ESI_DeliverChild(req, bo);
return;
}
if (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) &&
!RFC2616_Req_Gzip(req->http)) {
/*
* We don't know what it uncompresses to
* XXX: we could cache that, but would still deliver
* XXX: with multiple writes because of the gunzip buffer
*/
req->res_mode |= RES_GUNZIP;
VDP_push(req, VDP_gunzip, NULL, 1);
}
if (req->res_mode & RES_ESI)
assert(req->resp_len < 0);
/*
* Range comes after the others and pushes on bottom because it
* can generate a correct C-L header.
*/
if (cache_param->http_range_support && http_IsStatus(req->resp, 200)) {
http_SetHeader(req->resp, "Accept-Ranges: bytes");
if (req->wantbody && http_GetHdr(req->http, H_Range, &r))
VRG_dorange(req, r);
}
if ((req->objcore->flags & OC_F_PRIVATE) &&
!strcasecmp(http_GetMethod(req->http0), "HEAD")) {
/* HEAD+pass is allowed to send the C-L through unmolested. */
......
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