Commit 39e1e6cc authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move the header-filtering another step backwards, so it comes before

the VCL methods vcl_miss and vcl_pass.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1638 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 7eac67db
......@@ -411,7 +411,8 @@ void http_GetReq(struct http *to, struct http *fm);
void http_CopyReq(struct http *to, struct http *fm);
void http_CopyResp(struct http *to, struct http *fm);
void http_SetResp(struct http *to, const char *proto, const char *status, const char *response);
void http_FilterHeader(struct worker *w, int fd, struct http *to, struct http *fm, unsigned how);
void http_FilterFields(struct worker *w, int fd, struct http *to, struct http *fm, unsigned how);
void http_FilterHeader(struct sess *sp, unsigned how);
void http_PutProtocol(struct worker *w, int fd, struct http *to, const char *protocol);
void http_PutStatus(struct worker *w, int fd, struct http *to, int status);
void http_PutResponse(struct worker *w, int fd, struct http *to, const char *response);
......
......@@ -278,27 +278,9 @@ DOT errfetch [label="ERROR",shape=plaintext]
static int
cnt_fetch(struct sess *sp)
{
struct bereq *bereq;
struct http *hp;
char *b;
int i;
bereq = vbe_new_bereq();
AN(bereq);
hp = bereq->http;
hp->logtag = HTTP_Tx;
http_GetReq(hp, sp->http);
http_FilterHeader(sp->wrk, sp->fd, hp, sp->http, HTTPH_R_FETCH);
http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Varnish: %u", sp->xid);
http_PrintfHeader(sp->wrk, sp->fd, hp,
"X-Forwarded-for: %s", sp->addr);
if (!http_GetHdr(hp, H_Host, &b)) {
http_PrintfHeader(sp->wrk, sp->fd, hp, "Host: %s",
sp->backend->hostname);
}
sp->bereq = bereq;
AN(sp->bereq);
i = Fetch(sp);
vbe_free_bereq(sp->bereq);
sp->bereq = NULL;
......@@ -527,6 +509,7 @@ static int
cnt_miss(struct sess *sp)
{
http_FilterHeader(sp, HTTPH_R_FETCH);
VCL_miss_method(sp);
if (sp->handling == VCL_RET_ERROR) {
sp->obj->cacheable = 0;
......@@ -542,6 +525,8 @@ cnt_miss(struct sess *sp)
HSH_Deref(sp->obj);
sp->obj = NULL;
sp->step = STP_PASS;
vbe_free_bereq(sp->bereq);
sp->bereq = NULL;
return (0);
}
if (sp->handling == VCL_RET_FETCH) {
......@@ -583,6 +568,8 @@ cnt_pass(struct sess *sp)
AZ(sp->obj);
http_FilterHeader(sp, HTTPH_R_PASS);
VCL_pass_method(sp);
if (sp->handling == VCL_RET_ERROR) {
sp->step = STP_ERROR;
......@@ -624,34 +611,15 @@ DOT err_pipe [label="ERROR",shape=plaintext]
static int
cnt_pipe(struct sess *sp)
{
struct bereq *bereq;
struct http *hp;
char *b;
sp->wrk->acct.pipe++;
bereq = vbe_new_bereq();
XXXAN(bereq);
hp = bereq->http;
hp->logtag = HTTP_Tx;
http_CopyReq(hp, sp->http);
http_FilterHeader(sp->wrk, sp->fd, hp, sp->http, HTTPH_R_PIPE);
http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Varnish: %u", sp->xid);
http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Forwarded-for: %s", sp->addr);
/* XXX: does this belong in VCL ? */
if (!http_GetHdr(hp, H_Host, &b)) {
http_PrintfHeader(sp->wrk, sp->fd, hp, "Host: %s",
sp->backend->hostname);
}
http_FilterHeader(sp, HTTPH_R_PIPE);
VCL_pipe_method(sp);
if (sp->handling == VCL_RET_ERROR)
INCOMPL();
sp->bereq = bereq;
PipeSession(sp);
sp->step = STP_DONE;
return (0);
......
......@@ -321,7 +321,7 @@ Fetch(struct sess *sp)
hp2->logtag = HTTP_Obj;
http_CopyResp(hp2, hp);
http_FilterHeader(sp->wrk, sp->fd, hp2, hp, HTTPH_A_INS);
http_FilterFields(sp->wrk, sp->fd, hp2, hp, HTTPH_A_INS);
http_CopyHome(sp->wrk, sp->fd, hp2);
if (body) {
......
......@@ -773,7 +773,7 @@ http_copyheader(struct worker *w, int fd, struct http *to, struct http *fm, unsi
/*--------------------------------------------------------------------*/
void
http_FilterHeader(struct worker *w, int fd, struct http *to, struct http *fm, unsigned how)
http_FilterFields(struct worker *w, int fd, struct http *to, struct http *fm, unsigned how)
{
unsigned u;
......@@ -792,6 +792,32 @@ http_FilterHeader(struct worker *w, int fd, struct http *to, struct http *fm, un
}
}
/*--------------------------------------------------------------------*/
void
http_FilterHeader(struct sess *sp, unsigned how)
{
struct bereq *bereq;
struct http *hp;
char *b;
bereq = vbe_new_bereq();
AN(bereq);
hp = bereq->http;
hp->logtag = HTTP_Tx;
http_GetReq(hp, sp->http);
http_FilterFields(sp->wrk, sp->fd, hp, sp->http, how);
http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Varnish: %u", sp->xid);
http_PrintfHeader(sp->wrk, sp->fd, hp,
"X-Forwarded-for: %s", sp->addr);
if (!http_GetHdr(hp, H_Host, &b)) {
http_PrintfHeader(sp->wrk, sp->fd, hp, "Host: %s",
sp->backend->hostname);
}
sp->bereq = bereq;
}
/*--------------------------------------------------------------------
* This function copies any header fields which reference foreign
* storage into our own WS.
......
......@@ -130,7 +130,8 @@ RES_WriteObj(struct sess *sp)
http_ClrHeader(sp->http);
sp->http->logtag = HTTP_Tx;
http_CopyResp(sp->http, &sp->obj->http);
http_FilterHeader(sp->wrk, sp->fd, sp->http, &sp->obj->http, HTTPH_A_DELIVER);
http_FilterFields(sp->wrk, sp->fd, sp->http, &sp->obj->http,
HTTPH_A_DELIVER);
if (sp->xid != sp->obj->xid)
http_PrintfHeader(sp->wrk, sp->fd, sp->http,
"X-Varnish: %u %u", sp->xid, sp->obj->xid);
......
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