[PATCH 1/2] Make HTTP_GetHdrPack magic header names conform to the format of regular headers
Martin Blix Grydeland
martin at varnish-software.com
Fri Sep 4 12:57:52 CEST 2015
---
bin/varnishd/cache/cache_ban.c | 2 +-
bin/varnishd/cache/cache_http.c | 17 +++++++++--------
bin/varnishd/cache/cache_vrt_var.c | 6 ++++--
3 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 699bcf5..64f3afe 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -857,7 +857,7 @@ ban_evaluate(struct worker *wrk, const uint8_t *bs, struct objcore *oc,
arg1 = HTTP_GetHdrPack(wrk, oc, bt.arg1_spec);
break;
case BANS_ARG_OBJSTATUS:
- arg1 = HTTP_GetHdrPack(wrk, oc, ":status");
+ arg1 = HTTP_GetHdrPack(wrk, oc, "\010:status:");
break;
default:
WRONG("Wrong BAN_ARG code");
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index e832992..a3aeba3 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -901,6 +901,12 @@ HTTP_GetHdrPack(struct worker *wrk, struct objcore *oc, const char *hdr)
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AN(hdr);
+ l = hdr[0];
+ assert(l > 0);
+ assert(l == strlen(hdr + 1));
+ assert(hdr[l] == ':');
+ hdr++;
+
ptr = ObjGetattr(wrk, oc, OA_HEADERS, NULL);
AN(ptr);
@@ -909,21 +915,16 @@ HTTP_GetHdrPack(struct worker *wrk, struct objcore *oc, const char *hdr)
VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr);
/* Skip PROTO, STATUS and REASON */
- if (!strcmp(hdr, ":proto"))
+ if (!strcmp(hdr, ":proto:"))
return (ptr);
ptr = strchr(ptr, '\0') + 1;
- if (!strcmp(hdr, ":status"))
+ if (!strcmp(hdr, ":status:"))
return (ptr);
ptr = strchr(ptr, '\0') + 1;
- if (!strcmp(hdr, ":reason"))
+ if (!strcmp(hdr, ":reason:"))
return (ptr);
ptr = strchr(ptr, '\0') + 1;
- l = hdr[0];
- assert(l == strlen(hdr + 1));
- assert(hdr[l] == ':');
- hdr++;
-
while (*ptr != '\0') {
if (!strncasecmp(ptr, hdr, l)) {
ptr += l;
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index cc302c5..77f3892 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -157,7 +157,8 @@ VRT_r_obj_proto(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
- return (HTTP_GetHdrPack(ctx->req->wrk, ctx->req->objcore, ":proto"));
+ return (HTTP_GetHdrPack(ctx->req->wrk, ctx->req->objcore,
+ "\007:proto:"));
}
const char *
@@ -167,7 +168,8 @@ VRT_r_obj_reason(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
- return (HTTP_GetHdrPack(ctx->req->wrk, ctx->req->objcore, ":reason"));
+ return (HTTP_GetHdrPack(ctx->req->wrk, ctx->req->objcore,
+ "\010:reason:"));
}
/*--------------------------------------------------------------------
--
2.1.4
More information about the varnish-dev
mailing list