Commit 28a648f6 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Give the "topline" header-id's a length-field in HTTPHdrPack.

Patch by:	martin	(slightly polished)
parent e79fce21
...@@ -845,6 +845,9 @@ unsigned HTTP1_Write(const struct worker *w, const struct http *hp, const int*); ...@@ -845,6 +845,9 @@ unsigned HTTP1_Write(const struct worker *w, const struct http *hp, const int*);
#define HTTPH(a, b, c) extern char b[]; #define HTTPH(a, b, c) extern char b[];
#include "tbl/http_headers.h" #include "tbl/http_headers.h"
#undef HTTPH #undef HTTPH
extern const char H__Status[];
extern const char H__Proto[];
extern const char H__Reason[];
/* cache_main.c */ /* cache_main.c */
#define VXID(u) ((u) & VSL_IDENTMASK) #define VXID(u) ((u) & VSL_IDENTMASK)
......
...@@ -857,7 +857,7 @@ ban_evaluate(struct worker *wrk, const uint8_t *bs, struct objcore *oc, ...@@ -857,7 +857,7 @@ ban_evaluate(struct worker *wrk, const uint8_t *bs, struct objcore *oc,
arg1 = HTTP_GetHdrPack(wrk, oc, bt.arg1_spec); arg1 = HTTP_GetHdrPack(wrk, oc, bt.arg1_spec);
break; break;
case BANS_ARG_OBJSTATUS: case BANS_ARG_OBJSTATUS:
arg1 = HTTP_GetHdrPack(wrk, oc, ":status"); arg1 = HTTP_GetHdrPack(wrk, oc, H__Status);
break; break;
default: default:
WRONG("Wrong BAN_ARG code"); WRONG("Wrong BAN_ARG code");
......
...@@ -44,6 +44,10 @@ ...@@ -44,6 +44,10 @@
#include "tbl/http_headers.h" #include "tbl/http_headers.h"
#undef HTTPH #undef HTTPH
const char H__Status[] = "\010:status:";
const char H__Proto[] = "\007:proto:";
const char H__Reason[] = "\010:reason:";
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
* These two functions are in an incestous relationship with the * These two functions are in an incestous relationship with the
* order of macros in include/tbl/vsl_tags_http.h * order of macros in include/tbl/vsl_tags_http.h
...@@ -901,6 +905,12 @@ HTTP_GetHdrPack(struct worker *wrk, struct objcore *oc, const char *hdr) ...@@ -901,6 +905,12 @@ HTTP_GetHdrPack(struct worker *wrk, struct objcore *oc, const char *hdr)
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AN(hdr); AN(hdr);
l = hdr[0];
assert(l > 0);
assert(l == strlen(hdr + 1));
assert(hdr[l] == ':');
hdr++;
ptr = ObjGetattr(wrk, oc, OA_HEADERS, NULL); ptr = ObjGetattr(wrk, oc, OA_HEADERS, NULL);
AN(ptr); AN(ptr);
...@@ -909,21 +919,16 @@ HTTP_GetHdrPack(struct worker *wrk, struct objcore *oc, const char *hdr) ...@@ -909,21 +919,16 @@ HTTP_GetHdrPack(struct worker *wrk, struct objcore *oc, const char *hdr)
VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr); VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr);
/* Skip PROTO, STATUS and REASON */ /* Skip PROTO, STATUS and REASON */
if (!strcmp(hdr, ":proto")) if (!strcmp(hdr, ":proto:"))
return (ptr); return (ptr);
ptr = strchr(ptr, '\0') + 1; ptr = strchr(ptr, '\0') + 1;
if (!strcmp(hdr, ":status")) if (!strcmp(hdr, ":status:"))
return (ptr); return (ptr);
ptr = strchr(ptr, '\0') + 1; ptr = strchr(ptr, '\0') + 1;
if (!strcmp(hdr, ":reason")) if (!strcmp(hdr, ":reason:"))
return (ptr); return (ptr);
ptr = strchr(ptr, '\0') + 1; ptr = strchr(ptr, '\0') + 1;
l = hdr[0];
assert(l == strlen(hdr + 1));
assert(hdr[l] == ':');
hdr++;
while (*ptr != '\0') { while (*ptr != '\0') {
if (!strncasecmp(ptr, hdr, l)) { if (!strncasecmp(ptr, hdr, l)) {
ptr += l; ptr += l;
......
...@@ -157,7 +157,7 @@ VRT_r_obj_proto(VRT_CTX) ...@@ -157,7 +157,7 @@ VRT_r_obj_proto(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_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, H__Proto));
} }
const char * const char *
...@@ -167,7 +167,7 @@ VRT_r_obj_reason(VRT_CTX) ...@@ -167,7 +167,7 @@ VRT_r_obj_reason(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_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, H__Reason));
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment