[master] af1b857 More VDP polishing

Poul-Henning Kamp phk at FreeBSD.org
Tue Oct 28 12:42:18 CET 2014


commit af1b857ce703a58ce769d1fe6c6c991510a98e27
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Oct 28 07:43:47 2014 +0000

    More VDP polishing

diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index c32f760..583abc5 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -289,6 +289,8 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv,
 			return (-1);
 		VGZ_Obuf(vg, vg->m_buf, vg->m_sz);
 		*priv = vg;
+		http_Unset(req->resp, H_Content_Length);
+		http_Unset(req->resp, H_Content_Encoding);
 		return (0);
 	}
 
diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c
index ed08bf5..2ba4587 100644
--- a/bin/varnishd/cache/cache_range.c
+++ b/bin/varnishd/cache/cache_range.c
@@ -148,9 +148,8 @@ VRG_dorange(struct req *req, struct busyobj *bo, const char *r)
 	http_PrintfHeader(req->resp, "Content-Range: bytes %jd-%jd/%jd",
 	    (intmax_t)low, (intmax_t)high, (intmax_t)len);
 	http_Unset(req->resp, H_Content_Length);
-	if (req->res_mode & RES_LEN)
-		http_PrintfHeader(req->resp, "Content-Length: %jd",
-		    (intmax_t)(1 + high - low));
+	http_PrintfHeader(req->resp, "Content-Length: %jd",
+	    (intmax_t)(1 + high - low));
 	http_PutResponse(req->resp, "HTTP/1.1", 206, NULL);
 
 	vrg_priv = WS_Alloc(req->ws, sizeof *vrg_priv);
@@ -159,5 +158,5 @@ VRG_dorange(struct req *req, struct busyobj *bo, const char *r)
 	vrg_priv->range_off = 0;
 	vrg_priv->range_low = low;
 	vrg_priv->range_high = high + 1;
-	VDP_push(req, vrg_range_bytes, vrg_priv, 0);
+	VDP_push(req, vrg_range_bytes, vrg_priv, 1);
 }
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index 4b09178..c1f3b91 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -100,12 +100,6 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 		    req->wrk, req->objcore));
 	}
 
-	if (cache_param->http_range_support && http_IsStatus(req->resp, 200)) {
-		http_SetHeader(req->resp, "Accept-Ranges: bytes");
-		if (req->wantbody && http_GetHdr(req->http, H_Range, &r))
-			VRG_dorange(req, bo, r);
-	}
-
 	if (cache_param->http_gzip_support &&
 	    ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) &&
 	    !RFC2616_Req_Gzip(req->http)) {
@@ -115,11 +109,20 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 		 * XXX: with multiple writes because of the gunzip buffer
 		 */
 		req->res_mode |= RES_GUNZIP;
-		http_Unset(req->resp, H_Content_Length);
-		http_Unset(req->resp, H_Content_Encoding);
 		VDP_push(req, VDP_gunzip, NULL, 0);
 	}
 
+	/*
+	 * Range comes after the others and pushes on bottom because it
+	 * can generate a correct C-L header.
+	 */
+	if (cache_param->http_range_support && http_IsStatus(req->resp, 200)) {
+		http_SetHeader(req->resp, "Accept-Ranges: bytes");
+		if (req->wantbody && http_GetHdr(req->http, H_Range, &r))
+			VRG_dorange(req, bo, r);
+	}
+
+
 	if (http_GetHdr(req->resp, H_Content_Length, NULL))
 		req->res_mode |= RES_LEN;
 



More information about the varnish-commit mailing list