[master] 7ac280c Clean up the setting of synthetic response headers a bit further, the last fixe was clearly not enough.

Poul-Henning Kamp phk at FreeBSD.org
Thu Jan 2 17:03:42 CET 2014


commit 7ac280c6f5067bae31c22a18342f2be600b51878
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jan 2 15:56:05 2014 +0000

    Clean up the setting of synthetic response headers a bit further,
    the last fixe was clearly not enough.

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index e7ef1bb..c2bdb32 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -145,10 +145,8 @@ make_it_503(struct busyobj *bo)
 {
 
 	HTTP_Setup(bo->beresp, bo->ws, bo->vsl, HTTP_Beresp);
-	bo->err_code = 503;
 	http_SetH(bo->beresp, HTTP_HDR_PROTO, "HTTP/1.1");
-	http_SetResp(bo->beresp,
-	    "HTTP/1.1", 503, "Backend fetch failed");
+	http_SetResp(bo->beresp, "HTTP/1.1", 503, "Backend fetch failed");
 	http_SetHeader(bo->beresp, "Content-Length: 0");
 	http_SetHeader(bo->beresp, "Connection: close");
 }
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index d7053cc..97abe39 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -515,7 +515,7 @@ http_SetResp(struct http *to, const char *proto, uint16_t status,
 	CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
 	http_SetH(to, HTTP_HDR_PROTO, proto);
 	assert(status >= 100 && status <= 999);
-	to->status = status;
+	http_PutStatus(to, status);
 	http_SetH(to, HTTP_HDR_RESPONSE, response);
 }
 
@@ -714,9 +714,12 @@ http_PutProtocol(const struct http *to, const char *protocol)
 void
 http_PutStatus(struct http *to, uint16_t status)
 {
+	char buf[4];
 
 	assert(status >= 100 && status <= 999);
 	to->status = status;
+	bprintf(buf, "%03d", status % 1000);
+	http_SetH(to, HTTP_HDR_STATUS, WS_Copy(to->ws, buf, sizeof buf));
 }
 
 void



More information about the varnish-commit mailing list