[master] 4c8f484 A bit of cleanup of the filtering stuff
Poul-Henning Kamp
phk at varnish-cache.org
Tue Jan 17 12:57:21 CET 2012
commit 4c8f484e24c5871dce6f6c4a19c40a6999fb5725
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Jan 17 11:57:11 2012 +0000
A bit of cleanup of the filtering stuff
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 9fc4e09..0b0b926 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -748,7 +748,7 @@ http_SetH(const struct http *to, unsigned n, const char *fm)
}
static void
-http_copyh(const struct http *to, const struct http *fm, unsigned n)
+http_linkh(const struct http *to, const struct http *fm, unsigned n)
{
assert(n < HTTP_HDR_FIRST);
@@ -776,25 +776,6 @@ http_SetResp(struct http *to, const char *proto, uint16_t status,
http_SetH(to, HTTP_HDR_RESPONSE, response);
}
-static void
-http_copyheader(struct worker *w, unsigned vsl_id, struct http *to,
- const struct http *fm, unsigned n)
-{
-
- CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
- CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
- assert(n < fm->shd);
- Tcheck(fm->hd[n]);
- if (to->nhd < to->shd) {
- to->hd[to->nhd] = fm->hd[n];
- to->hdf[to->nhd] = 0;
- to->nhd++;
- } else {
- VSC_C_main->losthdr++;
- WSLR(w, SLT_LostHeader, vsl_id, fm->hd[n]);
- }
-}
-
/*--------------------------------------------------------------------
* Estimate how much workspace we need to Filter this header according
* to 'how'.
@@ -847,7 +828,15 @@ http_filterfields(struct worker *w, unsigned vsl_id, struct http *to,
continue;
#include "tbl/http_headers.h"
#undef HTTPH
- http_copyheader(w, vsl_id, to, fm, u);
+ Tcheck(fm->hd[u]);
+ if (to->nhd < to->shd) {
+ to->hd[to->nhd] = fm->hd[u];
+ to->hdf[to->nhd] = 0;
+ to->nhd++;
+ } else {
+ VSC_C_main->losthdr++;
+ WSLR(w, SLT_LostHeader, vsl_id, fm->hd[u]);
+ }
}
}
@@ -862,12 +851,12 @@ http_FilterReq(const struct sess *sp, unsigned how)
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
hp->logtag = HTTP_Tx;
- http_copyh(hp, sp->req->http, HTTP_HDR_REQ);
- http_copyh(hp, sp->req->http, HTTP_HDR_URL);
+ http_linkh(hp, sp->req->http, HTTP_HDR_REQ);
+ http_linkh(hp, sp->req->http, HTTP_HDR_URL);
if (how == HTTPH_R_FETCH)
http_SetH(hp, HTTP_HDR_PROTO, "HTTP/1.1");
else
- http_copyh(hp, sp->req->http, HTTP_HDR_PROTO);
+ http_linkh(hp, sp->req->http, HTTP_HDR_PROTO);
http_filterfields(sp->wrk, sp->vsl_id, hp, sp->req->http, how);
http_PrintfHeader(sp->wrk, sp->vsl_id, hp,
"X-Varnish: %u", sp->req->xid);
@@ -884,7 +873,7 @@ http_FilterResp(const struct sess *sp, const struct http *fm, struct http *to,
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1");
to->status = fm->status;
- http_copyh(to, fm, HTTP_HDR_RESPONSE);
+ http_linkh(to, fm, HTTP_HDR_RESPONSE);
http_filterfields(sp->wrk, sp->vsl_id, to, fm, how);
}
More information about the varnish-commit
mailing list