[master] 44c0c6e Collect all aspect of resp.* creation together.

Poul-Henning Kamp phk at varnish-cache.org
Mon May 21 15:18:43 CEST 2012


commit 44c0c6edaf84a9800382e2db6cdd8c0f62643bb7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon May 21 13:17:50 2012 +0000

    Collect all aspect of resp.* creation together.

diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 48fdfe4..81b2b3b 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -267,14 +267,6 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req)
 	HTTP_Setup(req->resp, req->ws, req->vsl, HTTP_Resp);
 	RES_BuildHttp(sp);
 
-	if (req->obj->response == 200
-	    && req->http->conds && RFC2616_Do_Cond(sp)) {
-		req->wantbody = 0;
-		http_SetResp(req->resp, "HTTP/1.1", 304, "Not Modified");
-		http_Unset(req->resp, H_Content_Length);
-		http_Unset(req->resp, H_Transfer_Encoding);
-	}
-
 	VCL_deliver_method(sp);
 	switch (req->handling) {
 	case VCL_RET_DELIVER:
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index f92ca81..82cdafc 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -124,7 +124,15 @@ RES_BuildHttp(const struct sess *sp)
 		http_SetHeader(req->resp, "Accept-Ranges: bytes");
 	}
 
-	if (req->res_mode & RES_CHUNKED)
+	if (req->res_mode & RES_GUNZIP)
+		http_Unset(req->resp, H_Content_Encoding);
+
+	if (req->obj->response == 200
+	    && req->http->conds && RFC2616_Do_Cond(sp)) {
+		req->wantbody = 0;
+		http_SetResp(req->resp, "HTTP/1.1", 304, "Not Modified");
+		http_Unset(req->resp, H_Content_Length);
+	} else if (req->res_mode & RES_CHUNKED)
 		http_SetHeader(req->resp, "Transfer-Encoding: chunked");
 
 	http_Unset(req->resp, H_Date);
@@ -248,12 +256,6 @@ RES_WriteObj(struct sess *sp)
 	    http_GetHdr(req->http, H_Range, &r))
 		res_dorange(sp, r, &low, &high);
 
-	/*
-	 * Always remove C-E if client don't grok it
-	 */
-	if (req->res_mode & RES_GUNZIP)
-		http_Unset(req->resp, H_Content_Encoding);
-
 	WRW_Reserve(sp->wrk, &sp->fd, sp->req->vsl, sp->req->t_resp);
 
 	/*



More information about the varnish-commit mailing list