]> err.no Git - varnish/commitdiff
Use the default (or specified) Host: header for the backend in the
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 19 Aug 2008 07:19:50 +0000 (07:19 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 19 Aug 2008 07:19:50 +0000 (07:19 +0000)
probe requests.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3102 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_backend_poll.c
varnish-cache/include/vrt.h
varnish-cache/lib/libvcl/vcc_backend.c
varnish-cache/lib/libvcl/vcc_fixed_token.c

index 0590699fa50ae2cb15ea08bc31c0df869b449aed..bfc5eaf9719fc3671e80e37b5fc5138ef6db7531 100644 (file)
@@ -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);
index f0b3b1a701278d80833c844bde64503cac9219f2..35bc1d7fcbdefbf6a8d88af60d5c5a3761f81903 100644 (file)
@@ -48,6 +48,7 @@ struct sockaddr;
 extern void *vrt_magic_string_end;
 
 struct vrt_backend_probe {
+       char            *url;
        char            *request;
        double          timeout;
        double          interval;
index 64c8215805f8616aedd81c695b7c851ad108beeb..3edb15c3324738c8ab0d1a413ea5942befcbe60f 100644 (file)
@@ -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 }
 };
index 3b7f0f3ba139abea8daef453808f3a43a58f6d56..ff59e2282f0754fe61d3ed7c983af1d5427da21e 100644 (file)
@@ -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");