From: phk Date: Mon, 25 Jun 2007 10:37:11 +0000 (+0000) Subject: Implement resp.proto resp.status and resp.response. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92bd713e2d0dcfaff2aa72fc73d754b31e72a989;p=varnish Implement resp.proto resp.status and resp.response. Visible from vcl_fetch() only. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1560 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index 10a9cbb0..8d4623b8 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -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) { diff --git a/varnish-cache/include/vrt_obj.h b/varnish-cache/include/vrt_obj.h index a1264299..bd7e84b7 100644 --- a/varnish-cache/include/vrt_obj.h +++ b/varnish-cache/include/vrt_obj.h @@ -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 *); diff --git a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl index c504d3c1..12fd7cb8 100755 --- a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl +++ b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl @@ -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 *" diff --git a/varnish-cache/lib/libvcl/vcc_obj.c b/varnish-cache/lib/libvcl/vcc_obj.c index 62495019..9b408c16 100644 --- a/varnish-cache/lib/libvcl/vcc_obj.c +++ b/varnish-cache/lib/libvcl/vcc_obj.c @@ -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, ",