[experimental-ims] 3d43f62 Add support for banning on http.status
Geoff Simmons
geoff at varnish-cache.org
Tue Jan 10 00:03:34 CET 2012
commit 3d43f62b2e886ff115caa803eb45bccf72c806ce
Author: Tollef Fog Heen <tfheen at varnish-software.com>
Date: Mon Jan 2 12:58:03 2012 +0100
Add support for banning on http.status
Fixes: #1076
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index a884983..451e504 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -113,9 +113,10 @@ static bgthread_t ban_lurker;
#define BAN_OPER_MATCH 0x12
#define BAN_OPER_NMATCH 0x13
-#define BAN_ARG_URL 0x18
-#define BAN_ARG_REQHTTP 0x19
-#define BAN_ARG_OBJHTTP 0x1a
+#define BAN_ARG_URL 0x18
+#define BAN_ARG_REQHTTP 0x19
+#define BAN_ARG_OBJHTTP 0x1a
+#define BAN_ARG_OBJSTATUS 0x1b
/*--------------------------------------------------------------------
* Variables we can purge on
@@ -609,6 +610,7 @@ ban_evaluate(const uint8_t *bs, const struct http *objhttp,
struct ban_test bt;
const uint8_t *be;
char *arg1;
+ char buf[10];
be = bs + ban_len(bs);
bs += 13;
@@ -628,6 +630,10 @@ ban_evaluate(const uint8_t *bs, const struct http *objhttp,
case BAN_ARG_OBJHTTP:
(void)http_GetHdr(objhttp, bt.arg1_spec, &arg1);
break;
+ case BAN_ARG_OBJSTATUS:
+ arg1 = buf;
+ sprintf(buf, "%d", objhttp->status);
+ break;
default:
INCOMPL();
}
diff --git a/include/tbl/ban_vars.h b/include/tbl/ban_vars.h
index 669b9b1..65b17e0 100644
--- a/include/tbl/ban_vars.h
+++ b/include/tbl/ban_vars.h
@@ -35,3 +35,4 @@
PVAR("req.url", PVAR_REQ, BAN_ARG_URL)
PVAR("req.http.", PVAR_REQ|PVAR_HTTP, BAN_ARG_REQHTTP)
PVAR("obj.http.", PVAR_HTTP, BAN_ARG_OBJHTTP)
+PVAR("obj.status", 0, BAN_ARG_OBJSTATUS)
More information about the varnish-commit
mailing list