[master] 2ada3dc Connection: header handling is not version dependent.
Poul-Henning Kamp
phk at FreeBSD.org
Tue Sep 9 10:17:34 CEST 2014
commit 2ada3dc3016a7edefc0c0f41695f7caf977d8988
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Sep 9 08:17:01 2014 +0000
Connection: header handling is not version dependent.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 59d8703..34e51e7 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -196,7 +196,6 @@ struct http {
uint16_t status;
uint8_t protover;
uint8_t conds; /* If-* headers present */
- enum sess_close doclose;
};
/*--------------------------------------------------------------------
@@ -961,8 +960,6 @@ const char *http_GetReq(const struct http *hp);
int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
void http_CopyHome(const struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
-void http_MarkHeader(const struct http *, const char *hdr, unsigned hdrlen,
- uint8_t flag);
unsigned http_CountHdr(const struct http *hp, const char *hdr);
void http_CollectHdr(struct http *hp, const char *hdr);
void http_VSL_log(const struct http *hp);
@@ -970,6 +967,7 @@ void HTTP_Merge(struct objcore *, struct dstat *, struct http *to);
uint16_t HTTP_GetStatusPack(struct objcore *oc, struct dstat *ds);
const char *HTTP_GetHdrPack(struct objcore *, struct dstat *,
const char *hdr);
+enum sess_close http_DoConnection(struct http *hp);
/* cache_http1_proto.c */
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 17212a9..2b2d61f 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -267,7 +267,7 @@ http_findhdr(const struct http *hp, unsigned l, const char *hdr)
/*--------------------------------------------------------------------
*/
-void
+static void
http_MarkHeader(const struct http *hp, const char *hdr, unsigned hdrlen,
uint8_t flag)
{
@@ -572,6 +572,46 @@ http_GetContentLength(const struct http *hp)
return (cl);
}
+/*--------------------------------------------------------------------
+ */
+
+enum sess_close
+http_DoConnection(struct http *hp)
+{
+ char *p, *q;
+ enum sess_close retval;
+ unsigned u;
+
+ if (hp->protover < 11)
+ retval = SC_REQ_HTTP10;
+ else
+ retval = SC_NULL;
+
+ http_CollectHdr(hp, H_Connection);
+ if (!http_GetHdr(hp, H_Connection, &p))
+ return (retval);
+ AN(p);
+ for (; *p; p++) {
+ if (vct_issp(*p))
+ continue;
+ if (*p == ',')
+ continue;
+ for (q = p + 1; *q; q++)
+ if (*q == ',' || vct_issp(*q))
+ break;
+ u = pdiff(p, q);
+ if (u == 5 && !strncasecmp(p, "close", u))
+ retval = SC_REQ_CLOSE;
+ if (u == 10 && !strncasecmp(p, "keep-alive", u))
+ retval = SC_NULL;
+ http_MarkHeader(hp, p, u, HDF_FILTER);
+ if (!*q)
+ break;
+ p = q;
+ }
+ return (retval);
+}
+
/*--------------------------------------------------------------------*/
int
diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c
index 9555bbc..3ad3eee 100644
--- a/bin/varnishd/cache/cache_http1_fetch.c
+++ b/bin/varnishd/cache/cache_http1_fetch.c
@@ -235,6 +235,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, struct req *req)
return (-1);
}
- bo->doclose = hp->doclose;
+ bo->doclose = http_DoConnection(hp);
+
return (0);
}
diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c
index 5fe9345..8203987 100644
--- a/bin/varnishd/cache/cache_http1_fsm.c
+++ b/bin/varnishd/cache/cache_http1_fsm.c
@@ -340,7 +340,6 @@ http1_dissect(struct worker *wrk, struct req *req)
AZ(req->err_code);
req->ws_req = WS_Snapshot(req->ws);
- req->doclose = req->http->doclose;
assert(req->req_body_status != REQ_BODY_INIT);
diff --git a/bin/varnishd/cache/cache_http1_proto.c b/bin/varnishd/cache/cache_http1_proto.c
index fc98f47..97b184e 100644
--- a/bin/varnishd/cache/cache_http1_proto.c
+++ b/bin/varnishd/cache/cache_http1_proto.c
@@ -437,47 +437,6 @@ http1_proto_ver(struct http *hp)
hp->protover = 9;
}
-/*--------------------------------------------------------------------
- */
-
-static enum sess_close
-http1_DoConnection(struct http *hp)
-{
- char *p, *q;
- enum sess_close retval;
- unsigned u;
-
- if (hp->protover < 11)
- retval = SC_REQ_HTTP10;
- else
- retval = SC_NULL;;
-
- http_CollectHdr(hp, H_Connection);
- if (!http_GetHdr(hp, H_Connection, &p))
- return (retval);
- AN(p);
- for (; *p; p++) {
- if (vct_issp(*p))
- continue;
- if (*p == ',')
- continue;
- for (q = p + 1; *q; q++)
- if (*q == ',' || vct_issp(*q))
- break;
- u = pdiff(p, q);
- if (u == 5 && !strncasecmp(p, "close", u))
- retval = SC_REQ_CLOSE;
- if (u == 10 && !strncasecmp(p, "keep-alive", u))
- retval = SC_NULL;
- http_MarkHeader(hp, p, u, HDF_FILTER);
- if (!*q)
- break;
- p = q;
- }
- return (retval);
-}
-
-
/*--------------------------------------------------------------------*/
uint16_t
@@ -517,8 +476,6 @@ HTTP1_DissectRequest(struct http_conn *htc, struct http *hp)
if (htc->body_status == BS_ERROR)
return (400);
- hp->doclose = http1_DoConnection(hp);
-
return (retval);
}
@@ -573,8 +530,6 @@ HTTP1_DissectResponse(struct http *hp, struct http_conn *htc)
htc->body_status = http1_body_status(hp, htc);
- hp->doclose = http1_DoConnection(hp);
-
return (retval);
}
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 032c88d..1f0189e 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -717,6 +717,8 @@ cnt_recv(struct worker *wrk, struct req *req)
return (REQ_FSM_MORE);
}
+ req->doclose = http_DoConnection(req->http);
+
/* By default we use the first backend */
AZ(req->director_hint);
req->director_hint = req->vcl->director[0];
More information about the varnish-commit
mailing list