Mailing List Archive

r1638 - trunk/varnish-cache/bin/varnishd
Author: phk
Date: 2007-07-03 23:50:31 +0200 (Tue, 03 Jul 2007)
New Revision: 1638

Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_http.c
trunk/varnish-cache/bin/varnishd/cache_response.c
Log:
Move the header-filtering another step backwards, so it comes before
the VCL methods vcl_miss and vcl_pass.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-07-03 21:40:14 UTC (rev 1637)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-07-03 21:50:31 UTC (rev 1638)
@@ -411,7 +411,8 @@
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);

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-07-03 21:40:14 UTC (rev 1637)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-07-03 21:50:31 UTC (rev 1638)
@@ -278,27 +278,9 @@
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 @@
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 @@
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 @@

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 @@
static int
cnt_pipe(struct sess *sp)
{
- struct bereq *bereq;
- struct http *hp;
- char *b;

sp->wrk->acct.pipe++;
+ http_FilterHeader(sp, HTTPH_R_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);
- }
-
VCL_pipe_method(sp);

if (sp->handling == VCL_RET_ERROR)
INCOMPL();

- sp->bereq = bereq;
PipeSession(sp);
sp->step = STP_DONE;
return (0);

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-07-03 21:40:14 UTC (rev 1637)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-07-03 21:50:31 UTC (rev 1638)
@@ -321,7 +321,7 @@

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) {

Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-07-03 21:40:14 UTC (rev 1637)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-07-03 21:50:31 UTC (rev 1638)
@@ -773,7 +773,7 @@
/*--------------------------------------------------------------------*/

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 @@
}
}

+/*--------------------------------------------------------------------*/
+
+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.

Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2007-07-03 21:40:14 UTC (rev 1637)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2007-07-03 21:50:31 UTC (rev 1638)
@@ -130,7 +130,8 @@
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);