Commit 60d0f497 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Use the default (or specified) Host: header for the backend in the

probe requests.



git-svn-id: http://www.varnish-cache.org/svn/trunk@3102 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 3b5b0c4c
......@@ -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);
......
......@@ -48,6 +48,7 @@ struct sockaddr;
extern void *vrt_magic_string_end;
struct vrt_backend_probe {
char *url;
char *request;
double timeout;
double interval;
......
......@@ -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 }
};
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment