Commit 155f11a4 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Adding the default Host: header is a matter between the backend

and V1F, it has nothing to do with the VDI layer.
parent 57ff5102
......@@ -717,7 +717,7 @@ void VBO_waitstate(struct busyobj *bo, enum busyobj_state_e want);
/* cache_http1_fetch.c [V1F] */
int V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo);
int V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host);
void V1F_Setup_Fetch(struct vfp_ctx *vfc, struct http_conn *htc);
/* cache_http1_fsm.c [HTTP1] */
......
......@@ -62,19 +62,6 @@ struct vbe_dir {
const struct vrt_backend *vrt;
};
/*--------------------------------------------------------------------
* Create default Host: header for backend request
*/
void
VDI_AddHostHeader(struct http *hp, const struct vbc *vbc)
{
CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC);
CHECK_OBJ_NOTNULL(vbc->vdis, VDI_SIMPLE_MAGIC);
http_PrintfHeader(hp,
"Host: %s", vbc->vdis->vrt->hosthdr);
}
/*--------------------------------------------------------------------*/
/* Private interface from backend_cfg.c */
......@@ -425,10 +412,12 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
struct busyobj *bo)
{
int i;
struct vbe_dir *vs;
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
i = vbe_dir_getfd(d, bo);
if (i < 0) {
......@@ -437,7 +426,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
}
AN(bo->htc);
i = V1F_fetch_hdr(wrk, bo);
i = V1F_fetch_hdr(wrk, bo, vs->vrt->hosthdr);
/*
* If we recycle a backend connection, there is a finite chance
* that the backend closed it before we get a request to it.
......@@ -455,7 +444,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
return (-1);
}
AN(bo->htc);
i = V1F_fetch_hdr(wrk, bo);
i = V1F_fetch_hdr(wrk, bo, vs->vrt->hosthdr);
}
if (i != 0) {
vbe_dir_finish(d, wrk, bo);
......
......@@ -37,7 +37,6 @@
#include "cache.h"
// #include "cache_backend.h"
#include "cache_director.h"
/* Resolve director --------------------------------------------------*/
......
......@@ -74,6 +74,5 @@ int VDI_GetBody(struct worker *wrk, struct busyobj *bo);
void VDI_Finish(struct worker *wrk, struct busyobj *bo);
int VDI_GetHttp1Fd(struct worker *wrk, struct busyobj *);
int VDI_Healthy(const struct director *, const struct busyobj *);
void VDI_AddHostHeader(struct http *to, const struct vbc *vbc);
void VBE_Init(void);
......@@ -74,7 +74,7 @@ vbf_iter_req_body(struct req *req, void *priv, void *ptr, size_t l)
*/
int
V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host)
{
struct vbc *vc;
struct http *hp;
......@@ -101,8 +101,8 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
* header if one is necessary. This cannot be done in the VCL
* because the backend may be chosen by a director.
*/
if (!http_GetHdr(bo->bereq, H_Host, NULL))
VDI_AddHostHeader(bo->bereq, vc);
if (!http_GetHdr(bo->bereq, H_Host, NULL) && def_host != NULL)
http_PrintfHeader(hp, "Host: %s", def_host);
if (bo->req != NULL &&
bo->req->req_body_status == REQ_BODY_WITHOUT_LEN) {
......
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