Mailing List Archive

r919 - in trunk/varnish-cache: bin/varnishd include lib/libvcl
Author: phk
Date: 2006-09-06 11:54:49 +0200 (Wed, 06 Sep 2006)
New Revision: 919

Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt.c
trunk/varnish-cache/include/vrt.h
trunk/varnish-cache/include/vrt_obj.h
trunk/varnish-cache/lib/libvcl/vcc_compile.c
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
trunk/varnish-cache/lib/libvcl/vcc_obj.c
Log:
Add support for inspecting response headers.


Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2006-09-06 09:18:06 UTC (rev 918)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2006-09-06 09:54:49 UTC (rev 919)
@@ -42,13 +42,24 @@
/*--------------------------------------------------------------------*/

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);
}

Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2006-09-06 09:18:06 UTC (rev 918)
+++ trunk/varnish-cache/include/vrt.h 2006-09-06 09:54:49 UTC (rev 919)
@@ -45,7 +45,7 @@
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 */

Modified: trunk/varnish-cache/include/vrt_obj.h
===================================================================
--- trunk/varnish-cache/include/vrt_obj.h 2006-09-06 09:18:06 UTC (rev 918)
+++ trunk/varnish-cache/include/vrt_obj.h 2006-09-06 09:54:49 UTC (rev 919)
@@ -30,3 +30,5 @@
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 *);

Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c 2006-09-06 09:18:06 UTC (rev 918)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c 2006-09-06 09:54:49 UTC (rev 919)
@@ -375,7 +375,7 @@
{
char *p;
struct var *v;
- int i;
+ int i, w;

(void)tl;

@@ -388,7 +388,11 @@
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;

Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2006-09-06 09:18:06 UTC (rev 918)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2006-09-06 09:54:49 UTC (rev 919)
@@ -513,7 +513,7 @@
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);

Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2006-09-06 09:18:06 UTC (rev 918)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2006-09-06 09:54:49 UTC (rev 919)
@@ -22,6 +22,7 @@
{ obj.cacheable BOOL }
{ obj.ttl TIME }
{ req.http. HEADER }
+ { resp.http. HEADER }
}

set tt(IP) "const unsigned char *"

Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_obj.c 2006-09-06 09:18:06 UTC (rev 918)
+++ trunk/varnish-cache/lib/libvcl/vcc_obj.c 2006-09-06 09:54:49 UTC (rev 919)
@@ -62,6 +62,10 @@
"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 @@
"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"
;