From: Willy Tarreau Date: Fri, 13 Jun 2014 14:11:48 +0000 (+0200) Subject: MINOR: capture: extend the captures to support non-header keys X-Git-Tag: v1.5.0~37 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=54da8db40be730f272173941a494f7d5ec3bbb3e;p=thirdparty%2Fhaproxy.git MINOR: capture: extend the captures to support non-header keys This patch adds support for captures with no header name. The purpose is to allow extra captures to be defined and logged along with the header captures. --- diff --git a/include/types/capture.h b/include/types/capture.h index e37cc483f9..cd8f2a782a 100644 --- a/include/types/capture.h +++ b/include/types/capture.h @@ -27,8 +27,8 @@ struct cap_hdr { struct cap_hdr *next; - char *name; /* header name, case insensitive */ - int namelen; /* length of the header name, to speed-up lookups */ + char *name; /* header name, case insensitive, NULL if not header */ + int namelen; /* length of the header name, to speed-up lookups, 0 if !name */ int len; /* capture length, not including terminal zero */ int index; /* index in the output array */ struct pool_head *pool; /* pool of pre-allocated memory area of (len+1) bytes */ diff --git a/src/proto_http.c b/src/proto_http.c index bd9b13af3b..082f1616de 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -1029,7 +1029,7 @@ struct pool_head *pool2_uniqueid; /* * Capture headers from message starting at according to header list - * , and fill the structure appropriately. + * , and fill the pointers appropriately. */ void capture_headers(char *som, struct hdr_idx *idx, char **cap, struct cap_hdr *cap_hdr) @@ -1054,7 +1054,7 @@ void capture_headers(char *som, struct hdr_idx *idx, sov++; for (h = cap_hdr; h; h = h->next) { - if ((h->namelen == col - sol) && + if (h->namelen && (h->namelen == col - sol) && (strncasecmp(sol, h->name, h->namelen) == 0)) { if (cap[h->index] == NULL) cap[h->index] =