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 enum req_fsm_nxt cnt_recv(struct worker *wrk, struct req *req) { unsigned recv_handling; struct SHA256Context sha256ctx; const char *xff; const char *ci, *cp; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); AN(req->vcl); AZ(req->objcore); AZ(req->err_code); AZ(isnan(req->t_first)); AZ(isnan(req->t_prev)); AZ(isnan(req->t_req)); ci = SES_Get_String_Attr(req->sp, SA_CLIENT_IP); cp = SES_Get_String_Attr(req->sp, SA_CLIENT_PORT); VSLb(req->vsl, SLT_ReqStart, "%s %s", ci, cp); http_VSL_log(req->http); if (req->restarts == 0) { /* * This really should be done earlier, but we want to capture * it in the VSL log. */ http_CollectHdr(req->http, H_X_Forwarded_For); if (http_GetHdr(req->http, H_X_Forwarded_For, &xff)) { http_Unset(req->http, H_X_Forwarded_For); http_PrintfHeader(req->http, "X-Forwarded-For: %s, %s", xff, ci); } else { http_PrintfHeader(req->http, "X-Forwarded-For: %s", ci); } } /* By default we use the first backend */ AZ(req->director_hint); req->director_hint = VCL_DefaultDirector(req->vcl); AN(req->director_hint); req->d_ttl = -1; req->disable_esi = 0; req->hash_always_miss = 0; req->hash_ignore_busy = 0; req->client_identity = NULL; http_CollectHdr(req->http, H_Cache_Control); VFP_Setup(req->htc->vfc); req->htc->vfc->http = req->http; req->htc->vfc->wrk = wrk; if (req->transport->req_body != NULL) { req->transport->req_body(req); if (req->req_body_status == REQ_BODY_FAIL) { req->doclose = SC_OVERLOAD; return (REQ_FSM_DONE); } } VCL_recv_method(req->vcl, wrk, req, NULL, NULL); /* Attempts to cache req.body may fail */ if (req->req_body_status == REQ_BODY_FAIL) { req->doclose = SC_RX_BODY; return (REQ_FSM_DONE); } recv_handling = wrk->handling; /* We wash the A-E header here for the sake of VRY */ if (cache_param->http_gzip_support && (recv_handling != VCL_RET_PIPE) && (recv_handling != VCL_RET_PASS)) { if (RFC2616_Req_Gzip(req->http)) { http_ForceHeader(req->http, H_Accept_Encoding, "gzip"); } else { http_Unset(req->http, H_Accept_Encoding); } } SHA256_Init(&sha256ctx); VCL_hash_method(req->vcl, wrk, req, NULL, &sha256ctx); assert(wrk->handling == VCL_RET_LOOKUP); SHA256_Final(req->digest, &sha256ctx); switch(recv_handling) { case VCL_RET_PURGE: req->req_step = R_STP_PURGE; return (REQ_FSM_MORE); case VCL_RET_HASH: req->req_step = R_STP_LOOKUP; return (REQ_FSM_MORE); case VCL_RET_PIPE: if (req->esi_level == 0) { req->req_step = R_STP_PIPE; return (REQ_FSM_MORE); } VSLb(req->vsl, SLT_VCL_Error, "vcl_recv{} returns pipe for ESI included object." " Doing pass."); req->req_step = R_STP_PASS; return (REQ_FSM_DONE); case VCL_RET_PASS: req->req_step = R_STP_PASS; return (REQ_FSM_MORE); case VCL_RET_SYNTH: req->req_step = R_STP_SYNTH; return (REQ_FSM_MORE); default: WRONG("Illegal return from vcl_recv{}"); } }
static int cnt_recv(const struct worker *wrk, struct req *req) { unsigned recv_handling; struct SHA256Context sha256ctx; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->obj); AZ(req->busyobj); VSLb(req->vsl, SLT_ReqStart, "%s %s", req->sp->addr, req->sp->port); if (req->err_code) { req->req_step = R_STP_ERROR; return (0); } /* By default we use the first backend */ AZ(req->director); req->director = req->vcl->director[0]; AN(req->director); EXP_Clr(&req->exp); req->disable_esi = 0; req->hash_always_miss = 0; req->hash_ignore_busy = 0; req->client_identity = NULL; http_CollectHdr(req->http, H_Cache_Control); VCL_recv_method(req); recv_handling = req->handling; if (cache_param->http_gzip_support && (recv_handling != VCL_RET_PIPE) && (recv_handling != VCL_RET_PASS)) { if (RFC2616_Req_Gzip(req->http)) { http_Unset(req->http, H_Accept_Encoding); http_SetHeader(req->http, "Accept-Encoding: gzip"); } else { http_Unset(req->http, H_Accept_Encoding); } } req->sha256ctx = &sha256ctx; /* so HSH_AddString() can find it */ SHA256_Init(req->sha256ctx); VCL_hash_method(req); assert(req->handling == VCL_RET_HASH); SHA256_Final(req->digest, req->sha256ctx); req->sha256ctx = NULL; if (!strcmp(req->http->hd[HTTP_HDR_REQ].b, "HEAD")) req->wantbody = 0; else req->wantbody = 1; switch(recv_handling) { case VCL_RET_LOOKUP: req->req_step = R_STP_LOOKUP; return (0); case VCL_RET_PIPE: if (req->esi_level > 0) { /* XXX: VSL something */ INCOMPL(); return (1); } req->req_step = R_STP_PIPE; return (0); case VCL_RET_PASS: req->req_step = R_STP_PASS; return (0); case VCL_RET_ERROR: req->req_step = R_STP_ERROR; return (0); default: WRONG("Illegal action in vcl_recv{}"); } }
static enum req_fsm_nxt cnt_recv(struct worker *wrk, struct req *req) { unsigned recv_handling; struct SHA256Context sha256ctx; char *xff; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->objcore); AZ(req->obj); AZ(req->objcore); AZ(isnan(req->t_first)); AZ(isnan(req->t_prev)); AZ(isnan(req->t_req)); VSLb(req->vsl, SLT_ReqStart, "%s %s", req->sp->client_addr_str, req->sp->client_port_str); http_VSL_log(req->http); if (req->err_code) { req->req_step = R_STP_SYNTH; return (REQ_FSM_MORE); } /* By default we use the first backend */ AZ(req->director_hint); req->director_hint = req->vcl->director[0]; AN(req->director_hint); req->d_ttl = -1; req->disable_esi = 0; req->hash_always_miss = 0; req->hash_ignore_busy = 0; req->client_identity = NULL; if (req->restarts == 0) { if (http_GetHdr(req->http, H_X_Forwarded_For, &xff)) { http_Unset(req->http, H_X_Forwarded_For); http_PrintfHeader(req->http, "X-Forwarded-For: %s, %s", xff, req->sp->client_addr_str); } else { http_PrintfHeader(req->http, "X-Forwarded-For: %s", req->sp->client_addr_str); } } http_CollectHdr(req->http, H_Cache_Control); VCL_recv_method(req->vcl, wrk, req, NULL, req->http->ws); /* Attempts to cache req.body may fail */ if (req->req_body_status == REQ_BODY_FAIL) { return (REQ_FSM_DONE); } recv_handling = wrk->handling; /* We wash the A-E header here for the sake of VRY */ if (cache_param->http_gzip_support && (recv_handling != VCL_RET_PIPE) && (recv_handling != VCL_RET_PASS)) { if (RFC2616_Req_Gzip(req->http)) { http_ForceHeader(req->http, H_Accept_Encoding, "gzip"); } else { http_Unset(req->http, H_Accept_Encoding); } } req->sha256ctx = &sha256ctx; /* so HSH_AddString() can find it */ SHA256_Init(req->sha256ctx); VCL_hash_method(req->vcl, wrk, req, NULL, req->http->ws); assert(wrk->handling == VCL_RET_LOOKUP); SHA256_Final(req->digest, req->sha256ctx); req->sha256ctx = NULL; if (!strcmp(req->http->hd[HTTP_HDR_METHOD].b, "HEAD")) req->wantbody = 0; else req->wantbody = 1; switch(recv_handling) { case VCL_RET_PURGE: req->req_step = R_STP_PURGE; return (REQ_FSM_MORE); case VCL_RET_HASH: req->req_step = R_STP_LOOKUP; return (REQ_FSM_MORE); case VCL_RET_PIPE: if (req->esi_level == 0) { req->req_step = R_STP_PIPE; return (REQ_FSM_MORE); } VSLb(req->vsl, SLT_VCL_Error, "vcl_recv{} returns pipe for ESI included object." " Doing pass."); req->req_step = R_STP_PASS; return (REQ_FSM_DONE); case VCL_RET_PASS: req->req_step = R_STP_PASS; return (REQ_FSM_MORE); case VCL_RET_SYNTH: req->req_step = R_STP_SYNTH; return (REQ_FSM_MORE); default: WRONG("Illegal return from vcl_recv{}"); } }
static enum req_fsm_nxt cnt_recv(struct worker *wrk, struct req *req) { unsigned recv_handling; struct SHA256Context sha256ctx; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->objcore); AZ(req->obj); AZ(req->objcore); VSLb(req->vsl, SLT_ReqStart, "%s %s", req->sp->addr, req->sp->port); if (req->err_code) { req->req_step = R_STP_ERROR; return (REQ_FSM_MORE); } /* By default we use the first backend */ AZ(req->director); req->director = req->vcl->director[0]; AN(req->director); EXP_Clr(&req->exp); req->disable_esi = 0; req->hash_always_miss = 0; req->hash_ignore_busy = 0; req->client_identity = NULL; http_CollectHdr(req->http, H_Cache_Control); VCL_recv_method(req->vcl, wrk, req, NULL, req->http->ws); recv_handling = wrk->handling; if (cache_param->http_gzip_support && (recv_handling != VCL_RET_PIPE) && (recv_handling != VCL_RET_PASS)) { if (RFC2616_Req_Gzip(req->http)) { http_Unset(req->http, H_Accept_Encoding); http_SetHeader(req->http, "Accept-Encoding: gzip"); } else { http_Unset(req->http, H_Accept_Encoding); } } req->sha256ctx = &sha256ctx; /* so HSH_AddString() can find it */ SHA256_Init(req->sha256ctx); VCL_hash_method(req->vcl, wrk, req, NULL, req->http->ws); assert(wrk->handling == VCL_RET_LOOKUP); SHA256_Final(req->digest, req->sha256ctx); req->sha256ctx = NULL; if (!strcmp(req->http->hd[HTTP_HDR_METHOD].b, "HEAD")) req->wantbody = 0; else req->wantbody = 1; switch(recv_handling) { case VCL_RET_PURGE: req->req_step = R_STP_PURGE; return (REQ_FSM_MORE); case VCL_RET_HASH: req->req_step = R_STP_LOOKUP; return (REQ_FSM_MORE); case VCL_RET_PIPE: if (req->esi_level == 0) { req->req_step = R_STP_PIPE; return (REQ_FSM_MORE); } VSLb(req->vsl, SLT_VCL_Error, "vcl_recv{} returns pipe for ESI included object." " Doing pass."); req->req_step = R_STP_PASS; return (REQ_FSM_DONE); case VCL_RET_PASS: req->req_step = R_STP_PASS; return (REQ_FSM_MORE); case VCL_RET_ERROR: req->req_step = R_STP_ERROR; return (REQ_FSM_MORE); default: WRONG("Illegal return from vcl_recv{}"); } }
static int cnt_recv(struct sess *sp) { struct worker *wrk; unsigned recv_handling; 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); AZ(wrk->busyobj); assert(wrk->wrw.ciov == wrk->wrw.siov); /* By default we use the first backend */ AZ(sp->director); sp->director = sp->vcl->director[0]; AN(sp->director); sp->disable_esi = 0; sp->hash_always_miss = 0; sp->hash_ignore_busy = 0; sp->client_identity = NULL; http_CollectHdr(sp->http, H_Cache_Control); VCL_recv_method(sp); recv_handling = sp->handling; if (sp->restarts >= cache_param->max_restarts) { if (sp->err_code == 0) sp->err_code = 503; sp->step = STP_ERROR; return (0); } if (cache_param->http_gzip_support && (recv_handling != VCL_RET_PIPE) && (recv_handling != VCL_RET_PASS)) { if (RFC2616_Req_Gzip(sp)) { http_Unset(sp->http, H_Accept_Encoding); http_SetHeader(wrk, sp->vsl_id, sp->http, "Accept-Encoding: gzip"); } else { http_Unset(sp->http, H_Accept_Encoding); } } SHA256_Init(wrk->sha256ctx); VCL_hash_method(sp); assert(sp->handling == VCL_RET_HASH); SHA256_Final(sp->digest, wrk->sha256ctx); if (!strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD")) sp->wantbody = 0; else sp->wantbody = 1; sp->sendbody = 0; switch(recv_handling) { case VCL_RET_LOOKUP: /* XXX: discard req body, if any */ sp->step = STP_LOOKUP; return (0); case VCL_RET_PIPE: if (sp->esi_level > 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{}"); } }