[master] 57fe09e3d Kill a dead branch when building a probe request

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Feb 24 19:49:07 UTC 2020


commit 57fe09e3d3b387129a1ac6a9ab67bba8e411e75b
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Feb 24 20:29:44 2020 +0100

    Kill a dead branch when building a probe request
    
    We have two fallbacks in the absence of a .host_header field in the
    backend, one of which is systematic. We can build a non .request probe
    request with a single printf statement.
    
    Please note that when the .host field is in the form "$addr $port" we
    use that as the probe's host header. This behavior is not introduced by
    this change but ultimately we might want to do something about it and
    for example capture the first token from hosthdr with a txt.

diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c
index 252ae7ecb..23721fb94 100644
--- a/bin/varnishd/cache/cache_backend_probe.c
+++ b/bin/varnishd/cache/cache_backend_probe.c
@@ -586,12 +586,14 @@ vbp_build_req(struct vbp_target *vt, const struct vrt_backend_probe *vbp,
 	if (vbp->request != NULL) {
 		VSB_cat(vsb, vbp->request);
 	} else {
-		VSB_printf(vsb, "GET %s HTTP/1.1\r\n",
-		    vbp->url != NULL ?  vbp->url : "/");
-		if (be->hosthdr != NULL)
-			VSB_printf(vsb, "Host: %s\r\n", be->hosthdr);
-		VSB_cat(vsb, "Connection: close\r\n");
-		VSB_cat(vsb, "\r\n");
+		AN(be->hosthdr);
+		VSB_printf(vsb,
+		    "GET %s HTTP/1.1\r\n"
+		    "Host: %s\r\n"
+		    "Connection: close\r\n"
+		    "\r\n",
+		    vbp->url != NULL ?  vbp->url : "/",
+		    be->hosthdr);
 	}
 	AZ(VSB_finish(vsb));
 	vt->req = strdup(VSB_data(vsb));


More information about the varnish-commit mailing list