[master] 4339ecb The HTTP/2 draft -13 seems pretty final with respect to the Connection: header being a HTTP/1.x thing only.

Poul-Henning Kamp phk at FreeBSD.org
Mon Jul 14 13:19:32 CEST 2014


commit 4339ecb8b1f3d6ac65fc462996cca72f4f193f86
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jul 14 11:16:35 2014 +0000

    The HTTP/2 draft -13 seems pretty final with respect to the Connection:
    header being a HTTP/1.x thing only.
    
    Move the handling accordingly

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index dc781b6..e7b4ad6 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -946,9 +946,10 @@ void http_SetStatus(struct http *to, uint16_t status);
 const char *http_GetReq(const struct http *hp);
 int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
 int http_IsHdr(const txt *hh, const char *hdr);
-enum sess_close http_DoConnection(const struct http *);
 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);
 void http_CollectHdr(struct http *hp, const char *hdr);
 void http_VSL_log(const struct http *hp);
 void http_Merge(const struct http *fm, struct http *to, int not_ce);
@@ -971,6 +972,7 @@ ssize_t HTTP1_Read(struct http_conn *htc, void *d, size_t len);
 enum htc_status_e HTTP1_Complete(struct http_conn *htc);
 uint16_t HTTP1_DissectRequest(struct req *);
 uint16_t HTTP1_DissectResponse(struct http *sp, const struct http_conn *htc);
+enum sess_close HTTP1_DoConnection(const struct http *);
 unsigned HTTP1_Write(const struct worker *w, const struct http *hp, const int*);
 
 #define HTTPH(a, b, c) extern char b[];
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index ec1afae..f7d9477 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -264,6 +264,23 @@ http_findhdr(const struct http *hp, unsigned l, const char *hdr)
 }
 
 /*--------------------------------------------------------------------
+ */
+
+void
+http_MarkHeader(const struct http *hp, const char *hdr, unsigned hdrlen,
+    uint8_t flag)
+{
+	unsigned u;
+
+	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
+
+	u = http_findhdr(hp, hdrlen, hdr);
+	if (u == 0)
+		return;
+	hp->hdf[u] |= flag;
+}
+
+/*--------------------------------------------------------------------
  * This function collapses multiple headerlines of the same name.
  * The lines are joined with a comma, according to [rfc2616, 4.2bot, p32]
  */
@@ -489,45 +506,6 @@ http_GetHdrField(const struct http *hp, const char *hdr,
 	return (i);
 }
 
-/*--------------------------------------------------------------------
- * XXX: redo with http_GetHdrField() ?
- */
-
-enum sess_close
-http_DoConnection(const struct http *hp)
-{
-	char *p, *q;
-	enum sess_close ret;
-	unsigned u;
-
-	if (!http_GetHdr(hp, H_Connection, &p)) {
-		if (hp->protover < 11)
-			return (SC_REQ_HTTP10);
-		return (SC_NULL);
-	}
-	ret = SC_NULL;
-	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))
-			ret = SC_REQ_CLOSE;
-		u = http_findhdr(hp, u, p);
-		if (u != 0)
-			hp->hdf[u] |= HDF_FILTER;
-		if (!*q)
-			break;
-		p = q;
-	}
-	return (ret);
-}
-
 /*--------------------------------------------------------------------*/
 
 int
diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c
index 454ec28..8475511 100644
--- a/bin/varnishd/cache/cache_http1_fsm.c
+++ b/bin/varnishd/cache/cache_http1_fsm.c
@@ -380,7 +380,7 @@ http1_dissect(struct worker *wrk, struct req *req)
 
 	AZ(req->err_code);
 	req->ws_req = WS_Snapshot(req->ws);
-	req->doclose = http_DoConnection(req->http);
+	req->doclose = HTTP1_DoConnection(req->http);
 
 	http_Unset(req->http, H_Expect);
 
diff --git a/bin/varnishd/cache/cache_http1_proto.c b/bin/varnishd/cache/cache_http1_proto.c
index f0a1abc..99564b3 100644
--- a/bin/varnishd/cache/cache_http1_proto.c
+++ b/bin/varnishd/cache/cache_http1_proto.c
@@ -411,8 +411,6 @@ htc_proto_ver(struct http *hp)
 
 /*--------------------------------------------------------------------*/
 
-#include <stdio.h>
-
 uint16_t
 HTTP1_DissectRequest(struct req *req)
 {
@@ -506,6 +504,42 @@ HTTP1_DissectResponse(struct http *hp, const struct http_conn *htc)
 	return (retval);
 }
 
+/*--------------------------------------------------------------------
+ */
+
+enum sess_close
+HTTP1_DoConnection(const struct http *hp)
+{
+	char *p, *q;
+	enum sess_close ret;
+	unsigned u;
+
+	if (!http_GetHdr(hp, H_Connection, &p)) {
+		if (hp->protover < 11)
+			return (SC_REQ_HTTP10);
+		return (SC_NULL);
+	}
+	ret = SC_NULL;
+	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))
+			ret = SC_REQ_CLOSE;
+		http_MarkHeader(hp, p, u, HDF_FILTER);
+		if (!*q)
+			break;
+		p = q;
+	}
+	return (ret);
+}
+
 /*--------------------------------------------------------------------*/
 
 unsigned



More information about the varnish-commit mailing list