[master] d5affe5 Having wasted half an hour on it (again) it's time to kill the "response/reason" confusion for good.

Poul-Henning Kamp phk at FreeBSD.org
Wed Jun 4 10:06:25 CEST 2014


commit d5affe570d38cee48dcbdca911aed28399a4771d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jun 4 08:05:48 2014 +0000

    Having wasted half an hour on it (again) it's time to kill the
    "response/reason" confusion for good.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 2429ccd..681c857 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -984,7 +984,7 @@ void VGZ_WrwFlush(struct req *, struct vgz *vg);
 unsigned HTTP_estimate(unsigned nhttp);
 void HTTP_Copy(struct http *to, const struct http * const fm);
 struct http *HTTP_create(void *p, uint16_t nhttp);
-const char *http_StatusMessage(unsigned);
+const char *http_Status2Reason(unsigned);
 unsigned http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd);
 void HTTP_Init(void);
 void http_PutResponse(struct http *to, const char *proto, uint16_t status,
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index d4296cd..1b17cac 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -116,7 +116,7 @@ static struct http_msg {
 };
 
 const char *
-http_StatusMessage(unsigned status)
+http_Status2Reason(unsigned status)
 {
 	struct http_msg *mp;
 
@@ -568,7 +568,7 @@ http_ForceGet(const struct http *to)
 
 void
 http_PutResponse(struct http *to, const char *proto, uint16_t status,
-    const char *response)
+    const char *reason)
 {
 	char buf[4];
 
@@ -583,9 +583,9 @@ http_PutResponse(struct http *to, const char *proto, uint16_t status,
 	to->status = status;
 	bprintf(buf, "%03d", status % 1000);
 	http_PutField(to, HTTP_HDR_STATUS, buf);
-	if (response == NULL)
-		response = http_StatusMessage(status);
-	http_SetH(to, HTTP_HDR_RESPONSE, response);
+	if (reason == NULL)
+		reason = http_Status2Reason(status);
+	http_SetH(to, HTTP_HDR_REASON, reason);
 }
 
 /*--------------------------------------------------------------------
@@ -689,7 +689,7 @@ http_FilterResp(const struct http *fm, struct http *to, unsigned how)
 	http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1");
 	to->status = fm->status;
 	http_linkh(to, fm, HTTP_HDR_STATUS);
-	http_linkh(to, fm, HTTP_HDR_RESPONSE);
+	http_linkh(to, fm, HTTP_HDR_REASON);
 	http_filterfields(to, fm, how);
 }
 
@@ -708,7 +708,7 @@ http_Merge(const struct http *fm, struct http *to, int not_ce)
 	to->status = fm->status;
 	http_SetH(to, HTTP_HDR_PROTO, fm->hd[HTTP_HDR_PROTO].b);
 	http_SetH(to, HTTP_HDR_STATUS, fm->hd[HTTP_HDR_STATUS].b);
-	http_SetH(to, HTTP_HDR_RESPONSE, fm->hd[HTTP_HDR_RESPONSE].b);
+	http_SetH(to, HTTP_HDR_REASON, fm->hd[HTTP_HDR_REASON].b);
 
 	for (u = HTTP_HDR_FIRST; u < fm->nhd; u++)
 		fm->hdf[u] |= HDF_MARKER;
diff --git a/bin/varnishd/cache/cache_http1_proto.c b/bin/varnishd/cache/cache_http1_proto.c
index a896546..4daa814 100644
--- a/bin/varnishd/cache/cache_http1_proto.c
+++ b/bin/varnishd/cache/cache_http1_proto.c
@@ -310,7 +310,7 @@ htc_splitline(struct http *hp, const struct http_conn *htc, int req)
 	} else {
 		h1 = HTTP_HDR_PROTO;
 		h2 = HTTP_HDR_STATUS;
-		h3 = HTTP_HDR_RESPONSE;
+		h3 = HTTP_HDR_REASON;
 	}
 
 	/* Skip leading LWS */
@@ -493,13 +493,13 @@ HTTP1_DissectResponse(struct http *hp, const struct http_conn *htc)
 	} else
 		htc_proto_ver(hp);
 
-	if (hp->hd[HTTP_HDR_RESPONSE].b == NULL ||
-	    !Tlen(hp->hd[HTTP_HDR_RESPONSE])) {
+	if (hp->hd[HTTP_HDR_REASON].b == NULL ||
+	    !Tlen(hp->hd[HTTP_HDR_REASON])) {
 		/* Backend didn't send a response string, use the standard */
-		hp->hd[HTTP_HDR_RESPONSE].b =
-		    TRUST_ME(http_StatusMessage(hp->status));
-		hp->hd[HTTP_HDR_RESPONSE].e =
-		    strchr(hp->hd[HTTP_HDR_RESPONSE].b, '\0');
+		hp->hd[HTTP_HDR_REASON].b =
+		    TRUST_ME(http_Status2Reason(hp->status));
+		hp->hd[HTTP_HDR_REASON].e =
+		    strchr(hp->hd[HTTP_HDR_REASON].b, '\0');
 	}
 	return (retval);
 }
@@ -523,7 +523,7 @@ HTTP1_Write(const struct worker *w, const struct http *hp, int resp)
 
 		l += WRW_WriteH(w, &hp->hd[HTTP_HDR_STATUS], " ");
 
-		l += WRW_WriteH(w, &hp->hd[HTTP_HDR_RESPONSE], "\r\n");
+		l += WRW_WriteH(w, &hp->hd[HTTP_HDR_REASON], "\r\n");
 	} else {
 		AN(hp->hd[HTTP_HDR_URL].b);
 		l = WRW_WriteH(w, &hp->hd[HTTP_HDR_METHOD], " ");
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 08e3b77..4038693 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -63,7 +63,7 @@ VRT_error(const struct vrt_ctx *ctx, unsigned code, const char *reason)
 		code = 503;
 	ctx->req->err_code = (uint16_t)code;
 	ctx->req->err_reason =
-	    reason ? reason : http_StatusMessage(ctx->req->err_code);
+	    reason ? reason : http_Status2Reason(ctx->req->err_code);
 }
 
 /*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index d2e6647..293b029 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -122,11 +122,11 @@ VRT_HDR_LR(req,    url,		HTTP_HDR_URL)
 VRT_HDR_LR(req,    proto,	HTTP_HDR_PROTO)
 
 VRT_HDR_R(obj,    proto,	HTTP_HDR_PROTO)
-VRT_HDR_R(obj,    reason,	HTTP_HDR_RESPONSE)
+VRT_HDR_R(obj,    reason,	HTTP_HDR_REASON)
 VRT_STATUS_R(obj)
 
 VRT_HDR_LR(resp,   proto,	HTTP_HDR_PROTO)
-VRT_HDR_LR(resp,   reason,	HTTP_HDR_RESPONSE)
+VRT_HDR_LR(resp,   reason,	HTTP_HDR_REASON)
 VRT_STATUS_L(resp)
 VRT_STATUS_R(resp)
 
@@ -134,7 +134,7 @@ VRT_HDR_LR(bereq,  method,	HTTP_HDR_METHOD)
 VRT_HDR_LR(bereq,  url,		HTTP_HDR_URL)
 VRT_HDR_LR(bereq,  proto,	HTTP_HDR_PROTO)
 VRT_HDR_LR(beresp, proto,	HTTP_HDR_PROTO)
-VRT_HDR_LR(beresp, reason,	HTTP_HDR_RESPONSE)
+VRT_HDR_LR(beresp, reason,	HTTP_HDR_REASON)
 VRT_STATUS_L(beresp)
 VRT_STATUS_R(beresp)
 
diff --git a/include/tbl/vsl_tags_http.h b/include/tbl/vsl_tags_http.h
index 3a3ae50..ab09d70 100644
--- a/include/tbl/vsl_tags_http.h
+++ b/include/tbl/vsl_tags_http.h
@@ -55,7 +55,7 @@ SLTH(Protocol,	HTTP_HDR_PROTO,		1, 1, "protocol",
 SLTH(Status,	HTTP_HDR_STATUS,	0, 1, "status",
 	"The HTTP status code received.\n\n"
 )
-SLTH(Response,	HTTP_HDR_RESPONSE,	0, 1, "response",
+SLTH(Reason,	HTTP_HDR_REASON,	0, 1, "response",
 	"The HTTP response string received.\n\n"
 )
 SLTH(Header,	HTTP_HDR_FIRST,		1, 1, "header",



More information about the varnish-commit mailing list