Commit 35443881 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

More RFC2616 related argument cleanup

parent 66330133
...@@ -998,8 +998,8 @@ char *WS_Snapshot(struct ws *ws); ...@@ -998,8 +998,8 @@ char *WS_Snapshot(struct ws *ws);
/* rfc2616.c */ /* rfc2616.c */
void RFC2616_Ttl(struct busyobj *, unsigned xid); void RFC2616_Ttl(struct busyobj *, unsigned xid);
enum body_status RFC2616_Body(const struct sess *sp); enum body_status RFC2616_Body(struct busyobj *, struct dstat *);
unsigned RFC2616_Req_Gzip(const struct sess *sp); unsigned RFC2616_Req_Gzip(const struct http *);
int RFC2616_Do_Cond(const struct sess *sp); int RFC2616_Do_Cond(const struct sess *sp);
/* stevedore.c */ /* stevedore.c */
......
...@@ -238,7 +238,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) ...@@ -238,7 +238,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req)
} }
if (cache_param->http_gzip_support && req->obj->gziped && if (cache_param->http_gzip_support && req->obj->gziped &&
!RFC2616_Req_Gzip(sp)) { !RFC2616_Req_Gzip(req->http)) {
/* /*
* We don't know what it uncompresses to * We don't know what it uncompresses to
* XXX: we could cache that * XXX: we could cache that
...@@ -552,22 +552,24 @@ static int ...@@ -552,22 +552,24 @@ static int
cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req)
{ {
int i, need_host_hdr; int i, need_host_hdr;
struct busyobj *bo;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC);
CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); bo = wrk->busyobj;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
AN(req->director); AN(req->director);
AZ(wrk->busyobj->vbc); AZ(bo->vbc);
AZ(wrk->busyobj->should_close); AZ(bo->should_close);
AZ(req->storage_hint); AZ(req->storage_hint);
http_Setup(wrk->busyobj->beresp, wrk->busyobj->ws, wrk->busyobj->vsl); http_Setup(bo->beresp, bo->ws, bo->vsl);
need_host_hdr = !http_GetHdr(wrk->busyobj->bereq, H_Host, NULL); need_host_hdr = !http_GetHdr(bo->bereq, H_Host, NULL);
i = FetchHdr(sp, need_host_hdr, req->objcore == NULL); i = FetchHdr(sp, need_host_hdr, req->objcore == NULL);
/* /*
...@@ -589,35 +591,35 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) ...@@ -589,35 +591,35 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req)
* and we rely on their content outside of VCL, so collect them * and we rely on their content outside of VCL, so collect them
* into one line here. * into one line here.
*/ */
http_CollectHdr(wrk->busyobj->beresp, H_Cache_Control); http_CollectHdr(bo->beresp, H_Cache_Control);
http_CollectHdr(wrk->busyobj->beresp, H_Vary); http_CollectHdr(bo->beresp, H_Vary);
/* /*
* Figure out how the fetch is supposed to happen, before the * Figure out how the fetch is supposed to happen, before the
* headers are adultered by VCL * headers are adultered by VCL
* NB: Also sets other wrk variables * NB: Also sets other wrk variables
*/ */
wrk->busyobj->body_status = RFC2616_Body(sp); bo->body_status = RFC2616_Body(bo, &wrk->stats);
req->err_code = http_GetStatus(wrk->busyobj->beresp); req->err_code = http_GetStatus(bo->beresp);
/* /*
* What does RFC2616 think about TTL ? * What does RFC2616 think about TTL ?
*/ */
EXP_Clr(&wrk->busyobj->exp); EXP_Clr(&bo->exp);
wrk->busyobj->exp.entered = W_TIM_real(wrk); bo->exp.entered = W_TIM_real(wrk);
RFC2616_Ttl(wrk->busyobj, sp->req->xid); RFC2616_Ttl(bo, sp->req->xid);
/* pass from vclrecv{} has negative TTL */ /* pass from vclrecv{} has negative TTL */
if (req->objcore == NULL) if (req->objcore == NULL)
wrk->busyobj->exp.ttl = -1.; bo->exp.ttl = -1.;
AZ(wrk->busyobj->do_esi); AZ(bo->do_esi);
AZ(wrk->busyobj->do_pass); AZ(bo->do_pass);
VCL_fetch_method(sp); VCL_fetch_method(sp);
if (req->objcore != NULL && wrk->busyobj->do_pass) if (req->objcore != NULL && bo->do_pass)
req->objcore->flags |= OC_F_PASS; req->objcore->flags |= OC_F_PASS;
switch (req->handling) { switch (req->handling) {
...@@ -630,11 +632,11 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) ...@@ -630,11 +632,11 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req)
} }
/* We are not going to fetch the body, Close the connection */ /* We are not going to fetch the body, Close the connection */
VDI_CloseFd(wrk, &wrk->busyobj->vbc); VDI_CloseFd(wrk, &bo->vbc);
} }
/* Clean up partial fetch */ /* Clean up partial fetch */
AZ(wrk->busyobj->vbc); AZ(bo->vbc);
if (req->objcore != NULL) { if (req->objcore != NULL) {
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
...@@ -1384,7 +1386,7 @@ cnt_recv(struct sess *sp, const struct worker *wrk, struct req *req) ...@@ -1384,7 +1386,7 @@ cnt_recv(struct sess *sp, const struct worker *wrk, struct req *req)
if (cache_param->http_gzip_support && if (cache_param->http_gzip_support &&
(recv_handling != VCL_RET_PIPE) && (recv_handling != VCL_RET_PIPE) &&
(recv_handling != VCL_RET_PASS)) { (recv_handling != VCL_RET_PASS)) {
if (RFC2616_Req_Gzip(sp)) { if (RFC2616_Req_Gzip(req->http)) {
http_Unset(req->http, H_Accept_Encoding); http_Unset(req->http, H_Accept_Encoding);
http_SetHeader(req->http, "Accept-Encoding: gzip"); http_SetHeader(req->http, "Accept-Encoding: gzip");
} else { } else {
......
...@@ -179,27 +179,27 @@ RFC2616_Ttl(struct busyobj *bo, unsigned xid) ...@@ -179,27 +179,27 @@ RFC2616_Ttl(struct busyobj *bo, unsigned xid)
*/ */
enum body_status enum body_status
RFC2616_Body(const struct sess *sp) RFC2616_Body(struct busyobj *bo, struct dstat *stats)
{ {
struct http *hp; struct http *hp;
char *b; char *b;
hp = sp->wrk->busyobj->beresp; hp = bo->beresp;
if (hp->protover < 11 && !http_HdrIs(hp, H_Connection, "keep-alive")) if (hp->protover < 11 && !http_HdrIs(hp, H_Connection, "keep-alive"))
sp->wrk->busyobj->should_close = 1; bo->should_close = 1;
else if (http_HdrIs(hp, H_Connection, "close")) else if (http_HdrIs(hp, H_Connection, "close"))
sp->wrk->busyobj->should_close = 1; bo->should_close = 1;
else else
sp->wrk->busyobj->should_close = 0; bo->should_close = 0;
if (!strcasecmp(http_GetReq(sp->wrk->busyobj->bereq), "head")) { if (!strcasecmp(http_GetReq(bo->bereq), "head")) {
/* /*
* A HEAD request can never have a body in the reply, * A HEAD request can never have a body in the reply,
* no matter what the headers might say. * no matter what the headers might say.
* [RFC2516 4.3 p33] * [RFC2516 4.3 p33]
*/ */
sp->wrk->stats.fetch_head++; stats->fetch_head++;
return (BS_NONE); return (BS_NONE);
} }
...@@ -208,7 +208,7 @@ RFC2616_Body(const struct sess *sp) ...@@ -208,7 +208,7 @@ RFC2616_Body(const struct sess *sp)
* 1xx responses never have a body. * 1xx responses never have a body.
* [RFC2616 4.3 p33] * [RFC2616 4.3 p33]
*/ */
sp->wrk->stats.fetch_1xx++; stats->fetch_1xx++;
return (BS_NONE); return (BS_NONE);
} }
...@@ -217,7 +217,7 @@ RFC2616_Body(const struct sess *sp) ...@@ -217,7 +217,7 @@ RFC2616_Body(const struct sess *sp)
* 204 is "No Content", obviously don't expect a body. * 204 is "No Content", obviously don't expect a body.
* [RFC2616 10.2.5 p60] * [RFC2616 10.2.5 p60]
*/ */
sp->wrk->stats.fetch_204++; stats->fetch_204++;
return (BS_NONE); return (BS_NONE);
} }
...@@ -226,23 +226,23 @@ RFC2616_Body(const struct sess *sp) ...@@ -226,23 +226,23 @@ RFC2616_Body(const struct sess *sp)
* 304 is "Not Modified" it has no body. * 304 is "Not Modified" it has no body.
* [RFC2616 10.3.5 p63] * [RFC2616 10.3.5 p63]
*/ */
sp->wrk->stats.fetch_304++; stats->fetch_304++;
return (BS_NONE); return (BS_NONE);
} }
if (http_HdrIs(hp, H_Transfer_Encoding, "chunked")) { if (http_HdrIs(hp, H_Transfer_Encoding, "chunked")) {
sp->wrk->stats.fetch_chunked++; stats->fetch_chunked++;
return (BS_CHUNKED); return (BS_CHUNKED);
} }
if (http_GetHdr(hp, H_Transfer_Encoding, &b)) { if (http_GetHdr(hp, H_Transfer_Encoding, &b)) {
sp->wrk->stats.fetch_bad++; stats->fetch_bad++;
return (BS_ERROR); return (BS_ERROR);
} }
if (http_GetHdr(hp, H_Content_Length, if (http_GetHdr(hp, H_Content_Length,
&sp->wrk->busyobj->h_content_length)) { &bo->h_content_length)) {
sp->wrk->stats.fetch_length++; stats->fetch_length++;
return (BS_LENGTH); return (BS_LENGTH);
} }
...@@ -251,7 +251,7 @@ RFC2616_Body(const struct sess *sp) ...@@ -251,7 +251,7 @@ RFC2616_Body(const struct sess *sp)
* Keep alive with neither TE=Chunked or C-Len is impossible. * Keep alive with neither TE=Chunked or C-Len is impossible.
* We assume a zero length body. * We assume a zero length body.
*/ */
sp->wrk->stats.fetch_zero++; stats->fetch_zero++;
return (BS_ZERO); return (BS_ZERO);
} }
...@@ -259,7 +259,7 @@ RFC2616_Body(const struct sess *sp) ...@@ -259,7 +259,7 @@ RFC2616_Body(const struct sess *sp)
/* /*
* In this case, it is safe to just read what comes. * In this case, it is safe to just read what comes.
*/ */
sp->wrk->stats.fetch_close++; stats->fetch_close++;
return (BS_EOF); return (BS_EOF);
} }
...@@ -267,14 +267,14 @@ RFC2616_Body(const struct sess *sp) ...@@ -267,14 +267,14 @@ RFC2616_Body(const struct sess *sp)
/* /*
* With no Connection header, assume EOF. * With no Connection header, assume EOF.
*/ */
sp->wrk->stats.fetch_oldhttp++; stats->fetch_oldhttp++;
return (BS_EOF); return (BS_EOF);
} }
/* /*
* Fall back to EOF transfer. * Fall back to EOF transfer.
*/ */
sp->wrk->stats.fetch_eof++; stats->fetch_eof++;
return (BS_EOF); return (BS_EOF);
} }
...@@ -283,7 +283,7 @@ RFC2616_Body(const struct sess *sp) ...@@ -283,7 +283,7 @@ RFC2616_Body(const struct sess *sp)
*/ */
unsigned unsigned
RFC2616_Req_Gzip(const struct sess *sp) RFC2616_Req_Gzip(const struct http *hp)
{ {
...@@ -292,7 +292,7 @@ RFC2616_Req_Gzip(const struct sess *sp) ...@@ -292,7 +292,7 @@ RFC2616_Req_Gzip(const struct sess *sp)
* p104 says to not do q values for x-gzip, so we just test * p104 says to not do q values for x-gzip, so we just test
* for its existence. * for its existence.
*/ */
if (http_GetHdrData(sp->req->http, H_Accept_Encoding, "x-gzip", NULL)) if (http_GetHdrData(hp, H_Accept_Encoding, "x-gzip", NULL))
return (1); return (1);
/* /*
...@@ -300,7 +300,7 @@ RFC2616_Req_Gzip(const struct sess *sp) ...@@ -300,7 +300,7 @@ RFC2616_Req_Gzip(const struct sess *sp)
* We do not care a hoot if the client prefers some other * We do not care a hoot if the client prefers some other
* compression more than gzip: Varnish only does gzip. * compression more than gzip: Varnish only does gzip.
*/ */
if (http_GetHdrQ(sp->req->http, H_Accept_Encoding, "gzip") > 0.) if (http_GetHdrQ(hp, H_Accept_Encoding, "gzip") > 0.)
return (1); return (1);
/* Bad client, no gzip. */ /* Bad client, no gzip. */
......
...@@ -355,7 +355,7 @@ VRT_r_req_can_gzip(struct sess *sp) ...@@ -355,7 +355,7 @@ VRT_r_req_can_gzip(struct sess *sp)
{ {
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
return (RFC2616_Req_Gzip(sp)); return (RFC2616_Req_Gzip(sp->req->http));
} }
......
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