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

Add support for inspecting response headers.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@919 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 509b1a90
......@@ -42,13 +42,24 @@ VRT_count(struct sess *sp, unsigned u)
/*--------------------------------------------------------------------*/
char *
VRT_GetHdr(struct sess *sp, const char *n)
VRT_GetHdr(struct sess *sp, int where, const char *n)
{
char *p;
struct http *hp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AN(sp->http);
if (!http_GetHdr(sp->http, n, &p))
switch (where) {
case 1:
hp = sp->http;
break;
case 2:
hp = sp->vbc->http;
break;
default:
INCOMPL();
}
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
if (!http_GetHdr(hp, n, &p))
return (NULL);
return (p);
}
......
......@@ -45,7 +45,7 @@ int VRT_rewrite(const char *, const char *);
void VRT_error(struct sess *, unsigned, const char *);
int VRT_switch_config(const char *);
char *VRT_GetHdr(struct sess *, const char *);
char *VRT_GetHdr(struct sess *, int where, const char *);
void VRT_handling(struct sess *sp, unsigned hand);
/* Backend related */
......
......@@ -30,3 +30,5 @@ double VRT_r_obj_ttl(struct sess *);
void VRT_l_obj_ttl(struct sess *, double);
const char * VRT_r_req_http_(struct sess *);
void VRT_l_req_http_(struct sess *, const char *);
const char * VRT_r_resp_http_(struct sess *);
void VRT_l_resp_http_(struct sess *, const char *);
......@@ -375,7 +375,7 @@ HeaderVar(struct tokenlist *tl, struct token *t, struct var *vh)
{
char *p;
struct var *v;
int i;
int i, w;
(void)tl;
......@@ -388,7 +388,11 @@ HeaderVar(struct tokenlist *tl, struct token *t, struct var *vh)
p[i] = '\0';
v->name = p;
v->fmt = STRING;
asprintf(&p, "VRT_GetHdr(sp, \"\\%03o%s:\")",
if (!memcmp(vh->name, "req.", 4))
w = 1;
else
w = 2;
asprintf(&p, "VRT_GetHdr(sp, %d, \"\\%03o%s:\")", w,
(unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len);
assert(p != NULL);
v->rname = p;
......
......@@ -513,7 +513,7 @@ vcl_output_lang_h(FILE *f)
fputs("void VRT_error(struct sess *, unsigned, const char *);\n", f);
fputs("int VRT_switch_config(const char *);\n", f);
fputs("\n", f);
fputs("char *VRT_GetHdr(struct sess *, const char *);\n", f);
fputs("char *VRT_GetHdr(struct sess *, int where, const char *);\n", f);
fputs("void VRT_handling(struct sess *sp, unsigned hand);\n", f);
fputs("\n", f);
fputs("/* Backend related */\n", f);
......
......@@ -22,6 +22,7 @@ set spobj {
{ obj.cacheable BOOL }
{ obj.ttl TIME }
{ req.http. HEADER }
{ resp.http. HEADER }
}
set tt(IP) "const unsigned char *"
......
......@@ -62,6 +62,10 @@ struct var vcc_vars[] = {
"VRT_r_req_http_(sp)",
"VRT_l_req_http_(sp, ",
},
{ "resp.http.", HEADER, 10,
"VRT_r_resp_http_(sp)",
"VRT_l_resp_http_(sp, ",
},
{ NULL }
};
......@@ -98,4 +102,6 @@ const char *vrt_obj_h =
"void VRT_l_obj_ttl(struct sess *, double);\n"
"const char * VRT_r_req_http_(struct sess *);\n"
"void VRT_l_req_http_(struct sess *, const char *);\n"
"const char * VRT_r_resp_http_(struct sess *);\n"
"void VRT_l_resp_http_(struct sess *, const char *);\n"
;
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