]> err.no Git - varnish/commitdiff
Make sure there always is a Host: header in fetch requests.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 22 Jul 2006 16:55:17 +0000 (16:55 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 22 Jul 2006 16:55:17 +0000 (16:55 +0000)
We fill it in with backend.hostname, but this may not be optimal
(direct IP# etc etc) so VCL should be able to override it.

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

varnish-cache/bin/varnishd/cache_fetch.c

index 66dc8d367a14d3527001d29ddfc26cbd3e0593d1..9406458320d8d1a41779acfc468655381bfc3d54 100644 (file)
@@ -258,6 +258,7 @@ FetchHeaders(struct sess *sp)
        int i;
        struct vbe_conn *vc;
        struct worker *w;
+       char *b;
 
        CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
        CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
@@ -276,6 +277,10 @@ FetchHeaders(struct sess *sp)
        http_GetReq(vc->fd, vc->http, sp->http);
        http_FilterHeader(vc->fd, vc->http, sp->http, HTTPH_R_FETCH);
        http_PrintfHeader(vc->fd, vc->http, "X-Varnish: %u", sp->xid);
+       if (!http_GetHdr(vc->http, H_Host, &b)) {
+               http_PrintfHeader(vc->fd, vc->http, "Host: %s",
+                   sp->backend->hostname);
+       }
 
        sp->t_req = time(NULL);
        WRK_Reset(w, &vc->fd);