]> err.no Git - varnish/commitdiff
Add support for inspecting response headers.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 6 Sep 2006 09:54:49 +0000 (09:54 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 6 Sep 2006 09:54:49 +0000 (09:54 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@919 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_vrt.c
varnish-cache/include/vrt.h
varnish-cache/include/vrt_obj.h
varnish-cache/lib/libvcl/vcc_compile.c
varnish-cache/lib/libvcl/vcc_fixed_token.c
varnish-cache/lib/libvcl/vcc_gen_obj.tcl
varnish-cache/lib/libvcl/vcc_obj.c

index 6933e752958624c4b32aaf88866bb305d5631a0f..e969a736805e1c7707f1843f740701f3c858d5ba 100644 (file)
@@ -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);
 }
index 1915a0df47bd875d79b6921e411cc5d5e31f48cd..509a05784771cf51714aa8a5615147d5c389a87f 100644 (file)
@@ -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 */
index 1d06da02db7eed969ac1f63b21cf76391549d5f5..a82aed93b76b70fc76aa32880141ca70edd22a5b 100644 (file)
@@ -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 *);
index 73734bd54c227ade23dfc114c63b578264ccbd1b..cf33f610dd65fe78bdb1c4926f31d121e81a91bc 100644 (file)
@@ -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;
index 721dad3513bfb538b9338c71f3798fceb95df707..d716214ac31a527594dd3926ea3d2954ee364ee4 100644 (file)
@@ -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);
index 3f4d54d2a1d312aa311dbf96d273241095077ce5..ee9317a6adb618b2a3771b3d479d54e5e11aef43 100755 (executable)
@@ -22,6 +22,7 @@ set spobj {
         { obj.cacheable        BOOL }
         { obj.ttl      TIME }
         { req.http.    HEADER }
+        { resp.http.   HEADER }
 }
 
 set tt(IP)     "const unsigned char *"
index eff4974612743ba1769c50a9c1ab5fa633abfded..6b12473dbb4cad603d6b79d305a81ea020a6bf13 100644 (file)
@@ -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"
 ;