mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-05-04 20:46:11 +02:00
BUG/MEDIUM: http: hdr_cnt would not count any header when called without name
It's documented that these sample fetch functions should count all headers and/or all values when called with no name but in practice it's not what is being done as a missing name causes an immediate return and an absence of result. This bug is present in 1.5 as well and must be backported.
This commit is contained in:
parent
418b8c0c41
commit
601a4d1741
@ -10239,15 +10239,19 @@ smp_fetch_fhdr_cnt(struct proxy *px, struct session *l4, void *l7, unsigned int
|
||||
struct hdr_ctx ctx;
|
||||
const struct http_msg *msg = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_REQ) ? &txn->req : &txn->rsp;
|
||||
int cnt;
|
||||
const char *name = NULL;
|
||||
int len = 0;
|
||||
|
||||
if (!args || args->type != ARGT_STR)
|
||||
return 0;
|
||||
if (args && args->type == ARGT_STR) {
|
||||
name = args->data.str.str;
|
||||
len = args->data.str.len;
|
||||
}
|
||||
|
||||
CHECK_HTTP_MESSAGE_FIRST();
|
||||
|
||||
ctx.idx = 0;
|
||||
cnt = 0;
|
||||
while (http_find_full_header2(args->data.str.str, args->data.str.len, msg->chn->buf->p, idx, &ctx))
|
||||
while (http_find_full_header2(name, len, msg->chn->buf->p, idx, &ctx))
|
||||
cnt++;
|
||||
|
||||
smp->type = SMP_T_UINT;
|
||||
@ -10359,15 +10363,19 @@ smp_fetch_hdr_cnt(struct proxy *px, struct session *l4, void *l7, unsigned int o
|
||||
struct hdr_ctx ctx;
|
||||
const struct http_msg *msg = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_REQ) ? &txn->req : &txn->rsp;
|
||||
int cnt;
|
||||
const char *name = NULL;
|
||||
int len = 0;
|
||||
|
||||
if (!args || args->type != ARGT_STR)
|
||||
return 0;
|
||||
if (args && args->type == ARGT_STR) {
|
||||
name = args->data.str.str;
|
||||
len = args->data.str.len;
|
||||
}
|
||||
|
||||
CHECK_HTTP_MESSAGE_FIRST();
|
||||
|
||||
ctx.idx = 0;
|
||||
cnt = 0;
|
||||
while (http_find_header2(args->data.str.str, args->data.str.len, msg->chn->buf->p, idx, &ctx))
|
||||
while (http_find_header2(name, len, msg->chn->buf->p, idx, &ctx))
|
||||
cnt++;
|
||||
|
||||
smp->type = SMP_T_UINT;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user