]> err.no Git - varnish/commitdiff
Move the header-filtering another step backwards, so it comes before
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 3 Jul 2007 21:50:31 +0000 (21:50 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 3 Jul 2007 21:50:31 +0000 (21:50 +0000)
the VCL methods vcl_miss and vcl_pass.

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

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_fetch.c
varnish-cache/bin/varnishd/cache_http.c
varnish-cache/bin/varnishd/cache_response.c

index b15e84ece03df9a93427f7e2981f6c4135622389..238a31c7c9d95a34f76f5cfc7bff580a7216f0d5 100644 (file)
@@ -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);
index d9b871cde2be9618a212de03bd30f671671d50d0..acf274ac77d43b7de0b794b7b1f43179a8ea2bee 100644 (file)
@@ -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);
index 02485d3b6ab8f26e46e1f8ed6feff5da7755e3e6..b3034f69e79c72a56f4af021ad1f958dcccd47f0 100644 (file)
@@ -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) {
index 7bface8c006962bb0c866bb529524d4ec786ca6d..a731b42511e4147f5cef37b1baf24c86fc36dc58 100644 (file)
@@ -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.
index 934ba08635575811604f08d1ac13d7f2ea4ddeeb..045c461b37404449aef8d3f1e761767c691d011a 100644 (file)
@@ -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);