From: phk Date: Tue, 19 Aug 2008 07:19:50 +0000 (+0000) Subject: Use the default (or specified) Host: header for the backend in the X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8724fe65234d7bc5588eebc41997177714541641;p=varnish Use the default (or specified) Host: header for the backend in the probe requests. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3102 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_backend_poll.c b/varnish-cache/bin/varnishd/cache_backend_poll.c index 0590699f..bfc5eaf9 100644 --- a/varnish-cache/bin/varnishd/cache_backend_poll.c +++ b/varnish-cache/bin/varnishd/cache_backend_poll.c @@ -61,6 +61,7 @@ struct vbp_target { struct backend *backend; struct vrt_backend_probe probe; int stop; + char *req; int req_len; unsigned good; @@ -157,7 +158,7 @@ vbp_poke(struct vbp_target *vt) return (0); } - i = write(s, vt->probe.request, vt->req_len); + i = write(s, vt->req, vt->req_len); if (i != vt->req_len) { if (i < 0) vt->err_xmit |= 1; @@ -243,7 +244,7 @@ vbp_wrk_poll_backend(void *priv) vt->probe.threshold = 3; printf("Probe(\"%s\", %g, %g)\n", - vt->probe.request, + vt->req, vt->probe.timeout, vt->probe.interval); @@ -366,6 +367,7 @@ void VBP_Start(struct backend *b, struct vrt_backend_probe const *p) { struct vbp_target *vt; + struct vsb *vsb; ASSERT_CLI(); @@ -377,6 +379,27 @@ VBP_Start(struct backend *b, struct vrt_backend_probe const *p) } vt->backend = b; vt->probe = *p; + + if(p->request != NULL) { + vt->req = strdup(p->request); + XXXAN(vt->req); + } else { + vsb = vsb_newauto(); + XXXAN(vsb); + vsb_printf(vsb, "GET %s HTTP/1.1\r\n", + p->url != NULL ? p->url : "/"); + vsb_printf(vsb, "Connection: close\r\n"); + if (b->hosthdr != NULL) + vsb_printf(vsb, "Host: %s\r\n", b->hosthdr); + vsb_printf(vsb, "\r\n", b->hosthdr); + vsb_finish(vsb); + AZ(vsb_overflowed(vsb)); + vt->req = strdup(vsb_data(vsb)); + XXXAN(vt->req); + vsb_delete(vsb); + } + vt->req_len = strlen(vt->req); + b->probe = vt; VTAILQ_INSERT_TAIL(&vbp_list, vt, list); diff --git a/varnish-cache/include/vrt.h b/varnish-cache/include/vrt.h index f0b3b1a7..35bc1d7f 100644 --- a/varnish-cache/include/vrt.h +++ b/varnish-cache/include/vrt.h @@ -48,6 +48,7 @@ struct sockaddr; extern void *vrt_magic_string_end; struct vrt_backend_probe { + char *url; char *request; double timeout; double interval; diff --git a/varnish-cache/lib/libvcl/vcc_backend.c b/varnish-cache/lib/libvcl/vcc_backend.c index 64c82158..3edb15c3 100644 --- a/varnish-cache/lib/libvcl/vcc_backend.c +++ b/varnish-cache/lib/libvcl/vcc_backend.c @@ -364,12 +364,9 @@ vcc_ParseProbe(struct tokenlist *tl) vcc_ProbeRedef(tl, &t_did, t_field); ERRCHK(tl); ExpectErr(tl, CSTR); - Fb(tl, 0, "\t\t.request =\n"); - Fb(tl, 0, "\t\t\t\"GET \" "); + Fb(tl, 0, "\t\t.url = "); EncToken(tl->fb, tl->t); - Fb(tl, 0, " \" /HTTP/1.1\\r\\n\"\n"); - Fb(tl, 0, "\t\t\t\"Connection: close\\r\\n\"\n"); - Fb(tl, 0, "\t\t\t\"\\r\\n\",\n"); + Fb(tl, 0, ",\n"); vcc_NextToken(tl); } else if (vcc_IdIs(t_field, "request")) { vcc_ProbeRedef(tl, &t_did, t_field); @@ -703,7 +700,7 @@ static const struct dirlist { const char *name; parsedirector_f *func; } dirlist[] = { - { "random", vcc_ParseRandomDirector }, + { "random", vcc_ParseRandomDirector }, { "round-robin", vcc_ParseRoundRobinDirector }, { NULL, NULL } }; diff --git a/varnish-cache/lib/libvcl/vcc_fixed_token.c b/varnish-cache/lib/libvcl/vcc_fixed_token.c index 3b7f0f3b..ff59e228 100644 --- a/varnish-cache/lib/libvcl/vcc_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcc_fixed_token.c @@ -328,6 +328,7 @@ vcl_output_lang_h(struct vsb *sb) vsb_cat(sb, "extern void *vrt_magic_string_end;\n"); vsb_cat(sb, "\n"); vsb_cat(sb, "struct vrt_backend_probe {\n"); + vsb_cat(sb, " char *url;\n"); vsb_cat(sb, " char *request;\n"); vsb_cat(sb, " double timeout;\n"); vsb_cat(sb, " double interval;\n");