[experimental-ims] dd103d3 Cleanup http filtering operations:
Geoff Simmons
geoff at varnish-cache.org
Tue Jan 17 14:21:28 CET 2012
commit dd103d37091b9951f7705b240913ce638ded640c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Jan 17 10:15:14 2012 +0000
Cleanup http filtering operations:
Rename http_FilterHeader() to http_FilterReq()
Add http_FilterResp()
make http_FilterFields() static
remove http_CopyResp()
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 8891f12..817b7c7 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -797,12 +797,11 @@ void HTTP_Init(void);
void http_ClrHeader(struct http *to);
unsigned http_Write(struct worker *w, unsigned vsl_id, const struct http *hp,
int resp);
-void http_CopyResp(struct http *to, const struct http *fm);
void http_SetResp(struct http *to, const char *proto, uint16_t status,
const char *response);
-void http_FilterFields(struct worker *w, unsigned vsl_id, struct http *to,
- const struct http *fm, unsigned how);
-void http_FilterHeader(const struct sess *sp, unsigned how);
+void http_FilterReq(const struct sess *sp, unsigned how);
+void http_FilterResp(const struct sess *sp, const struct http *fm, struct http *to,
+ unsigned how);
void http_PutProtocol(struct worker *w, unsigned vsl_id, const struct http *to,
const char *protocol);
void http_PutStatus(struct http *to, uint16_t status);
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index df00fbc..a9c233b 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -876,9 +876,7 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
hp2 = req->obj->http;
hp2->logtag = HTTP_Obj;
- http_CopyResp(hp2, hp);
- http_FilterFields(wrk, sp->vsl_id, hp2, hp,
- pass ? HTTPH_R_PASS : HTTPH_A_INS);
+ http_FilterResp(sp, hp, hp2, pass ? HTTPH_R_PASS : HTTPH_A_INS);
http_CopyHome(wrk, sp->vsl_id, hp2);
if (http_GetHdr(hp, H_Last_Modified, &b))
@@ -1268,7 +1266,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req)
WS_Reset(wrk->ws, NULL);
wrk->busyobj = VBO_GetBusyObj(wrk);
http_Setup(wrk->busyobj->bereq, wrk->ws);
- http_FilterHeader(sp, HTTPH_R_FETCH);
+ http_FilterReq(sp, HTTPH_R_FETCH);
http_ForceGet(wrk->busyobj->bereq);
if (cache_param->http_gzip_support) {
/*
@@ -1360,7 +1358,7 @@ cnt_pass(struct sess *sp, struct worker *wrk, struct req *req)
WS_Reset(wrk->ws, NULL);
wrk->busyobj = VBO_GetBusyObj(wrk);
http_Setup(wrk->busyobj->bereq, wrk->ws);
- http_FilterHeader(sp, HTTPH_R_PASS);
+ http_FilterReq(sp, HTTPH_R_PASS);
wrk->connect_timeout = 0;
wrk->first_byte_timeout = 0;
@@ -1419,7 +1417,7 @@ cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req)
WS_Reset(wrk->ws, NULL);
wrk->busyobj = VBO_GetBusyObj(wrk);
http_Setup(wrk->busyobj->bereq, wrk->ws);
- http_FilterHeader(sp, 0);
+ http_FilterReq(sp, 0);
VCL_pipe_method(sp);
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 27a648f..9fc4e09 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -765,17 +765,6 @@ http_ForceGet(const struct http *to)
}
void
-http_CopyResp(struct http *to, const struct http *fm)
-{
-
- CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
- 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);
-}
-
-void
http_SetResp(struct http *to, const char *proto, uint16_t status,
const char *response)
{
@@ -838,8 +827,8 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd)
/*--------------------------------------------------------------------*/
-void
-http_FilterFields(struct worker *w, unsigned vsl_id, struct http *to,
+static void
+http_filterfields(struct worker *w, unsigned vsl_id, struct http *to,
const struct http *fm, unsigned how)
{
unsigned u;
@@ -865,7 +854,7 @@ http_FilterFields(struct worker *w, unsigned vsl_id, struct http *to,
/*--------------------------------------------------------------------*/
void
-http_FilterHeader(const struct sess *sp, unsigned how)
+http_FilterReq(const struct sess *sp, unsigned how)
{
struct http *hp;
@@ -879,11 +868,26 @@ http_FilterHeader(const struct sess *sp, unsigned how)
http_SetH(hp, HTTP_HDR_PROTO, "HTTP/1.1");
else
http_copyh(hp, sp->req->http, HTTP_HDR_PROTO);
- http_FilterFields(sp->wrk, sp->vsl_id, hp, sp->req->http, how);
+ 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);
}
+/*--------------------------------------------------------------------*/
+
+void
+http_FilterResp(const struct sess *sp, const struct http *fm, struct http *to,
+ unsigned how)
+{
+
+ CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
+ 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_filterfields(sp->wrk, sp->vsl_id, to, fm, how);
+}
+
/*--------------------------------------------------------------------
* This function copies any header fields which reference foreign
* storage into our own WS.
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index 3a19d4a..5724f07 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -117,9 +117,7 @@ RES_BuildHttp(const struct sess *sp)
http_ClrHeader(req->resp);
req->resp->logtag = HTTP_Tx;
- http_CopyResp(req->resp, req->obj->http);
- http_FilterFields(sp->wrk, sp->vsl_id, req->resp,
- req->obj->http, 0);
+ http_FilterResp(sp, req->obj->http, req->resp, 0);
if (!(sp->wrk->res_mode & RES_LEN)) {
http_Unset(req->resp, H_Content_Length);
More information about the varnish-commit
mailing list