static enum fetch_step vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) { CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo->req, REQ_MAGIC); AN(bo->director); AZ(bo->vbc); AZ(bo->should_close); AZ(bo->storage_hint); HTTP_Setup(bo->bereq0, bo->ws, bo->vsl, HTTP_Bereq); http_FilterReq(bo->bereq0, bo->req->http, bo->do_pass ? HTTPH_R_PASS : HTTPH_R_FETCH); if (!bo->do_pass) { // XXX: Forcing GET should happen in vcl_miss{} ? http_ForceGet(bo->bereq0); if (cache_param->http_gzip_support) { /* * We always ask the backend for gzip, even if the * client doesn't grok it. We will uncompress for * the minority of clients which don't. */ http_Unset(bo->bereq0, H_Accept_Encoding); http_SetHeader(bo->bereq0, "Accept-Encoding: gzip"); } } return (F_STP_STARTFETCH); }
static int cnt_recv(struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); AZ(sp->obj); SES_ResetBackendTimeouts(sp); /* By default we use the first backend */ AZ(sp->director); sp->director = sp->vcl->director[0]; AN(sp->director); sp->disable_esi = 0; VCL_recv_method(sp); if (sp->restarts >= params->max_restarts) { if (sp->err_code == 0) sp->err_code = 503; sp->step = STP_ERROR; return (0); } if (!strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD")) { sp->wantbody = 0; http_ForceGet(sp->http); } else sp->wantbody = 1; sp->sendbody = 0; switch(sp->handling) { case VCL_RET_LOOKUP: /* XXX: discard req body, if any */ sp->step = STP_LOOKUP; return (0); case VCL_RET_PIPE: if (sp->esis > 0) { /* XXX: VSL something */ INCOMPL(); /* sp->step = STP_DONE; */ return (1); } sp->step = STP_PIPE; return (0); case VCL_RET_PASS: sp->step = STP_PASS; return (0); case VCL_RET_ERROR: /* XXX: discard req body, if any */ sp->step = STP_ERROR; return (0); default: WRONG("Illegal action in vcl_recv{}"); } }
static int cnt_miss(struct worker *wrk, struct req *req) { struct busyobj *bo; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); bo = req->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AZ(req->obj); HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq); http_FilterReq(req, HTTPH_R_FETCH); http_ForceGet(bo->bereq); if (cache_param->http_gzip_support) { /* * We always ask the backend for gzip, even if the * client doesn't grok it. We will uncompress for * the minority of clients which don't. */ http_Unset(bo->bereq, H_Accept_Encoding); http_SetHeader(bo->bereq, "Accept-Encoding: gzip"); } VCL_miss_method(req); if (req->handling == VCL_RET_FETCH) { CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); req->req_step = R_STP_FETCH; return (0); } AZ(HSH_Deref(&wrk->stats, req->objcore, NULL)); req->objcore = NULL; http_Teardown(bo->bereq); VBO_DerefBusyObj(wrk, &req->busyobj); switch(req->handling) { case VCL_RET_ERROR: req->req_step = R_STP_ERROR; break; case VCL_RET_PASS: req->req_step = R_STP_PASS; break; case VCL_RET_RESTART: req->req_step = R_STP_RESTART; break; default: WRONG("Illegal action in vcl_miss{}"); } return (0); }
static enum fetch_step vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) { char *p; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo->req, REQ_MAGIC); AN(bo->director); AZ(bo->vbc); AZ(bo->should_close); AZ(bo->storage_hint); HTTP_Setup(bo->bereq0, bo->ws, bo->vsl, HTTP_Bereq); http_FilterReq(bo->bereq0, bo->req->http, bo->do_pass ? HTTPH_R_PASS : HTTPH_R_FETCH); if (!bo->do_pass) { // XXX: Forcing GET should happen in vcl_miss{} ? http_ForceGet(bo->bereq0); if (cache_param->http_gzip_support) { /* * We always ask the backend for gzip, even if the * client doesn't grok it. We will uncompress for * the minority of clients which don't. */ http_Unset(bo->bereq0, H_Accept_Encoding); http_SetHeader(bo->bereq0, "Accept-Encoding: gzip"); } } if (bo->ims_obj != NULL) { if (http_GetHdr(bo->ims_obj->http, H_Last_Modified, &p)) { http_PrintfHeader(bo->bereq0, "If-Modified-Since: %s", p); } else if (http_GetHdr(bo->ims_obj->http, H_ETag, &p)) { http_PrintfHeader(bo->bereq0, "If-None-Match: %s", p); } else { WRONG("Shouldn't have bo->ims_obj"); } } return (F_STP_STARTFETCH); }
static enum fetch_step vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) { char *p; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo->req, REQ_MAGIC); assert(bo->state == BOS_INVALID); AN(bo->director); AZ(bo->vbc); AZ(bo->should_close); AZ(bo->storage_hint); HTTP_Setup(bo->bereq0, bo->ws, bo->vsl, SLT_BereqMethod); http_FilterReq(bo->bereq0, bo->req->http, bo->do_pass ? HTTPH_R_PASS : HTTPH_R_FETCH); if (!bo->do_pass) { http_ForceGet(bo->bereq0); if (cache_param->http_gzip_support) http_ForceHeader(bo->bereq0, H_Accept_Encoding, "gzip"); AN(bo->req); bo->req = NULL; http_CopyHome(bo->bereq0); } if (bo->ims_obj != NULL && bo->ims_obj->http->status == 200) { if (http_GetHdr(bo->ims_obj->http, H_Last_Modified, &p)) { http_PrintfHeader(bo->bereq0, "If-Modified-Since: %s", p); } if (http_GetHdr(bo->ims_obj->http, H_ETag, &p)) { http_PrintfHeader(bo->bereq0, "If-None-Match: %s", p); } } VBO_setstate(bo, BOS_REQ_DONE); return (F_STP_STARTFETCH); }
static int cnt_miss(struct sess *sp) { struct worker *wrk; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); wrk = sp->wrk; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); AZ(wrk->obj); AN(wrk->objcore); CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); WS_Reset(wrk->ws, NULL); wrk->busyobj = VBO_GetBusyObj(wrk); http_Setup(wrk->busyobj->bereq, wrk->ws); http_FilterHeader(sp, HTTPH_R_FETCH); http_ForceGet(wrk->busyobj->bereq); if (cache_param->http_gzip_support) { /* * We always ask the backend for gzip, even if the * client doesn't grok it. We will uncompress for * the minority of clients which don't. */ http_Unset(wrk->busyobj->bereq, H_Accept_Encoding); http_SetHeader(wrk, sp->vsl_id, wrk->busyobj->bereq, "Accept-Encoding: gzip"); } wrk->connect_timeout = 0; wrk->first_byte_timeout = 0; wrk->between_bytes_timeout = 0; VCL_miss_method(sp); switch(sp->handling) { case VCL_RET_ERROR: AZ(HSH_Deref(wrk, wrk->objcore, NULL)); wrk->objcore = NULL; http_Setup(wrk->busyobj->bereq, NULL); VBO_DerefBusyObj(wrk, &wrk->busyobj); sp->step = STP_ERROR; return (0); case VCL_RET_PASS: AZ(HSH_Deref(wrk, wrk->objcore, NULL)); wrk->objcore = NULL; VBO_DerefBusyObj(wrk, &wrk->busyobj); sp->step = STP_PASS; return (0); case VCL_RET_FETCH: CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); sp->step = STP_FETCH; return (0); case VCL_RET_RESTART: AZ(HSH_Deref(wrk, wrk->objcore, NULL)); wrk->objcore = NULL; VBO_DerefBusyObj(wrk, &wrk->busyobj); INCOMPL(); default: WRONG("Illegal action in vcl_miss{}"); } }