[3.0] d9bc81c Add support for banning on http.status
Tollef Fog Heen
tfheen at varnish-cache.org
Mon Apr 29 13:23:05 CEST 2013
commit d9bc81ce8a1c3a444ec0c1a1632927633d4eae33
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_ban.c b/bin/varnishd/cache_ban.c
index c458ba0..6062f98 100644
--- a/bin/varnishd/cache_ban.c
+++ b/bin/varnishd/cache_ban.c
@@ -97,9 +97,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
@@ -582,6 +583,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;
@@ -599,6 +601,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/ban_vars.h b/include/ban_vars.h
index 669b9b1..65b17e0 100644
--- a/include/ban_vars.h
+++ b/include/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