From: phk Date: Sat, 22 Jul 2006 16:55:17 +0000 (+0000) Subject: Make sure there always is a Host: header in fetch requests. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=867674b2e18132b260783e5a96743399979ec20c;p=varnish Make sure there always is a Host: header in fetch requests. 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 --- diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index 66dc8d36..94064583 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -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);