struct backend *backend;
struct vrt_backend_probe probe;
int stop;
+ char *req;
int req_len;
unsigned good;
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;
vt->probe.threshold = 3;
printf("Probe(\"%s\", %g, %g)\n",
- vt->probe.request,
+ vt->req,
vt->probe.timeout,
vt->probe.interval);
VBP_Start(struct backend *b, struct vrt_backend_probe const *p)
{
struct vbp_target *vt;
+ struct vsb *vsb;
ASSERT_CLI();
}
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);
extern void *vrt_magic_string_end;
struct vrt_backend_probe {
+ char *url;
char *request;
double timeout;
double interval;
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);
const char *name;
parsedirector_f *func;
} dirlist[] = {
- { "random", vcc_ParseRandomDirector },
+ { "random", vcc_ParseRandomDirector },
{ "round-robin", vcc_ParseRoundRobinDirector },
{ NULL, NULL }
};
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");