Commit dd103d37 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Cleanup http filtering operations:

Rename http_FilterHeader() to http_FilterReq()
Add http_FilterResp()
make http_FilterFields() static
remove http_CopyResp()
parent 41a9730f
......@@ -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);
......
......@@ -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);
......
......@@ -764,17 +764,6 @@ http_ForceGet(const struct http *to)
http_SetH(to, HTTP_HDR_REQ, "GET");
}
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.
......
......@@ -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);
......
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