]> err.no Git - varnish/commitdiff
Implement resp.proto resp.status and resp.response.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 25 Jun 2007 10:37:11 +0000 (10:37 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 25 Jun 2007 10:37:11 +0000 (10:37 +0000)
Visible from vcl_fetch() only.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1560 d4fa192b-c00b-0410-8231-f00ffab90ce4

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

index 10a9cbb0b8f6904ac29165f44f1cac9ccb5e601e..8d4623b8c14a9b31df0923c5f77fc928772e68fc 100644 (file)
@@ -253,6 +253,32 @@ VREQ(proto, HTTP_HDR_PROTO)
 
 /*--------------------------------------------------------------------*/
 
+const char *
+VRT_r_resp_proto(struct sess *sp)
+{
+       CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+       CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
+       return (sp->obj->http.hd[HTTP_HDR_PROTO].b);
+}
+
+const char *
+VRT_r_resp_response(struct sess *sp)
+{
+       CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+       CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
+       return (sp->obj->http.hd[HTTP_HDR_RESPONSE].b);
+}
+
+int
+VRT_r_resp_status(struct sess *sp)
+{
+       CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+       CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
+       return (atoi(sp->obj->http.hd[HTTP_HDR_STATUS].b));
+}
+
+/*--------------------------------------------------------------------*/
+
 struct sockaddr *
 VRT_r_client_ip(struct sess *sp)
 {
index a12642992dd7e7f80668b65acdcca509b8f99764..bd7e84b732f57c346b160ffcea0fd1c99c9f692c 100644 (file)
@@ -36,5 +36,11 @@ unsigned VRT_r_obj_cacheable(struct sess *);
 void VRT_l_obj_cacheable(struct sess *, unsigned);
 double VRT_r_obj_ttl(struct sess *);
 void VRT_l_obj_ttl(struct sess *, double);
+const char * VRT_r_resp_proto(struct sess *);
+void VRT_l_resp_proto(struct sess *, const char *);
+int VRT_r_resp_status(struct sess *);
+void VRT_l_resp_status(struct sess *, int);
+const char * VRT_r_resp_response(struct sess *);
+void VRT_l_resp_response(struct sess *, const char *);
 const char * VRT_r_resp_http_(struct sess *);
 void VRT_l_resp_http_(struct sess *, const char *);
index c504d3c1f4b7d38fc20e75667251c7acf3f8af9d..12fd7cb80b2d069070bfb6f80676ba5f94cd4be2 100755 (executable)
@@ -52,6 +52,9 @@ set spobj {
   { obj.valid          BOOL    {                         hit fetch discard timeout} }
   { obj.cacheable      BOOL    {                         hit fetch discard timeout} }
   { obj.ttl            TIME    {                         hit fetch discard timeout} }
+  { resp.proto         STRING  {                             fetch                } }
+  { resp.status                INT     {                             fetch                } }
+  { resp.response      STRING  {                             fetch                } }
   { resp.http.         HEADER  {                             fetch                } }
 }
 
@@ -60,6 +63,7 @@ set tt(STRING)        "const char *"
 set tt(BOOL)   "unsigned"
 set tt(BACKEND)        "struct backend *"
 set tt(TIME)   "double"
+set tt(INT)    "int"
 set tt(HEADER) "const char *"
 set tt(HOSTNAME) "const char *"
 set tt(PORTNAME) "const char *"
index 624950190cb23bbf3acbd3b1eb33f0695ca8c81c..9b408c1637c4d8b87b4110584fcad0140953791f 100644 (file)
@@ -89,6 +89,21 @@ struct var vcc_vars[] = {
            "VRT_l_obj_ttl(sp, ",
            VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
        },
+       { "resp.proto", STRING, 10,
+           "VRT_r_resp_proto(sp)",
+           "VRT_l_resp_proto(sp, ",
+           VCL_MET_FETCH
+       },
+       { "resp.status", INT, 11,
+           "VRT_r_resp_status(sp)",
+           "VRT_l_resp_status(sp, ",
+           VCL_MET_FETCH
+       },
+       { "resp.response", STRING, 13,
+           "VRT_r_resp_response(sp)",
+           "VRT_l_resp_response(sp, ",
+           VCL_MET_FETCH
+       },
        { "resp.http.", HEADER, 10,
            "VRT_r_resp_http_(sp)",
            "VRT_l_resp_http_(sp, ",