[master] b86ffb9 Move 304/C-L/Body logic earlier, making it simpler

Poul-Henning Kamp phk at FreeBSD.org
Thu May 7 13:17:57 CEST 2015


commit b86ffb93487c107f8f92917bfd15c7a0223f42ed
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu May 7 09:45:38 2015 +0000

    Move 304/C-L/Body logic earlier, making it simpler

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index d8ade2d..42e67c3 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -131,6 +131,9 @@ cnt_deliver(struct worker *wrk, struct req *req)
 		req->wantbody = 0;
 	}
 
+	if (http_IsStatus(req->resp, 304))
+		req->wantbody = 0;
+
 	/* Grab a ref to the bo if there is one, and hand it down */
 	bo = HSH_RefBusy(req->objcore);
 	if (bo != NULL) {
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index e541f01..19857c1 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -95,11 +95,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 		RFC2616_Weaken_Etag(req->resp);
 		req->resp_len = -1;
 		VDP_push(req, VDP_ESI, NULL, 0);
-	} else if (http_IsStatus(req->resp, 304)) {
-		http_Unset(req->resp, H_Content_Length);
-		req->wantbody = 0;
-	} else if (bo == NULL && req->wantbody)
-		req->resp_len = ObjGetLen(req->wrk, req->objcore);
+	}
 
 	if (cache_param->http_gzip_support &&
 	    ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) &&
@@ -131,7 +127,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 		/* HEAD+pass is allowed to send the C-L through unmolested. */
 	} else {
 		http_Unset(req->resp, H_Content_Length);
-		if (req->resp_len >= 0 && !http_IsStatus(req->resp, 304)) 
+		if (req->resp_len >= 0 && !http_IsStatus(req->resp, 304))
 			http_PrintfHeader(req->resp,
 			    "Content-Length: %jd", req->resp_len);
 	}



More information about the varnish-commit mailing list