mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-18 01:14:38 +00:00
BUG/MINOR: http_fetch: Rely on the smp direction for "cookie()" and "hdr()"
A regression was introduced in the commit89dc49935
("BUG/MAJOR: http_fetch: Get the channel depending on the keyword used") on the samples "cookie()" and "hdr()". Unlike other samples manipulating the HTTP headers, these ones depend on the sample direction. To fix the bug, these samples use now their own functions. Depending on the sample direction, they call smp_fetch_cookie() and smp_fetch_hdr() with the appropriate keyword. Thanks to Yves Lafon to report this issue. This patch must be backported wherever the commit89dc49935
was backported. For now, 1.9 and 1.8.
This commit is contained in:
parent
b396f4d848
commit
c1f40dd492
@ -1435,6 +1435,16 @@ static int smp_fetch_hdr(const struct arg *args, struct sample *smp, const char
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Same than smp_fetch_hdr() but only relies on the sample direction to choose
|
||||||
|
* the right channel. So instead of duplicating the code, we just change the
|
||||||
|
* keyword and then fallback on smp_fetch_hdr().
|
||||||
|
*/
|
||||||
|
static int smp_fetch_chn_hdr(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||||
|
{
|
||||||
|
kw = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_REQ ? "req.hdr" : "res.hdr");
|
||||||
|
return smp_fetch_hdr(args, smp, kw, private);
|
||||||
|
}
|
||||||
|
|
||||||
/* 6. Check on HTTP header count. The number of occurrences is returned.
|
/* 6. Check on HTTP header count. The number of occurrences is returned.
|
||||||
* Accepts exactly 1 argument of type string.
|
* Accepts exactly 1 argument of type string.
|
||||||
*/
|
*/
|
||||||
@ -2289,6 +2299,16 @@ static int smp_fetch_cookie(const struct arg *args, struct sample *smp, const ch
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Same than smp_fetch_cookie() but only relies on the sample direction to
|
||||||
|
* choose the right channel. So instead of duplicating the code, we just change
|
||||||
|
* the keyword and then fallback on smp_fetch_cookie().
|
||||||
|
*/
|
||||||
|
static int smp_fetch_chn_cookie(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||||
|
{
|
||||||
|
kw = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_REQ ? "req.cook" : "res.cook");
|
||||||
|
return smp_fetch_cookie(args, smp, kw, private);
|
||||||
|
}
|
||||||
|
|
||||||
/* Iterate over all cookies present in a request to count how many occurrences
|
/* Iterate over all cookies present in a request to count how many occurrences
|
||||||
* match the name in args and args->data.str.len. If <multi> is non-null, then
|
* match the name in args and args->data.str.len. If <multi> is non-null, then
|
||||||
* multiple cookies may be parsed on the same line. The returned sample is of
|
* multiple cookies may be parsed on the same line. The returned sample is of
|
||||||
@ -2825,7 +2845,7 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
|
|||||||
* for ACL compatibility only.
|
* for ACL compatibility only.
|
||||||
*/
|
*/
|
||||||
{ "cook", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_HRQHV },
|
{ "cook", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_HRQHV },
|
||||||
{ "cookie", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_HRQHV|SMP_USE_HRSHV },
|
{ "cookie", smp_fetch_chn_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_HRQHV|SMP_USE_HRSHV },
|
||||||
{ "cook_cnt", smp_fetch_cookie_cnt, ARG1(0,STR), NULL, SMP_T_SINT, SMP_USE_HRQHV },
|
{ "cook_cnt", smp_fetch_cookie_cnt, ARG1(0,STR), NULL, SMP_T_SINT, SMP_USE_HRQHV },
|
||||||
{ "cook_val", smp_fetch_cookie_val, ARG1(0,STR), NULL, SMP_T_SINT, SMP_USE_HRQHV },
|
{ "cook_val", smp_fetch_cookie_val, ARG1(0,STR), NULL, SMP_T_SINT, SMP_USE_HRQHV },
|
||||||
|
|
||||||
@ -2833,7 +2853,7 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
|
|||||||
* only here to match the ACL's name, are request-only and are used for
|
* only here to match the ACL's name, are request-only and are used for
|
||||||
* ACL compatibility only.
|
* ACL compatibility only.
|
||||||
*/
|
*/
|
||||||
{ "hdr", smp_fetch_hdr, ARG2(0,STR,SINT), val_hdr, SMP_T_STR, SMP_USE_HRQHV|SMP_USE_HRSHV },
|
{ "hdr", smp_fetch_chn_hdr, ARG2(0,STR,SINT), val_hdr, SMP_T_STR, SMP_USE_HRQHV|SMP_USE_HRSHV },
|
||||||
{ "hdr_cnt", smp_fetch_hdr_cnt, ARG1(0,STR), NULL, SMP_T_SINT, SMP_USE_HRQHV },
|
{ "hdr_cnt", smp_fetch_hdr_cnt, ARG1(0,STR), NULL, SMP_T_SINT, SMP_USE_HRQHV },
|
||||||
{ "hdr_ip", smp_fetch_hdr_ip, ARG2(0,STR,SINT), val_hdr, SMP_T_IPV4, SMP_USE_HRQHV },
|
{ "hdr_ip", smp_fetch_hdr_ip, ARG2(0,STR,SINT), val_hdr, SMP_T_IPV4, SMP_USE_HRQHV },
|
||||||
{ "hdr_val", smp_fetch_hdr_val, ARG2(0,STR,SINT), val_hdr, SMP_T_SINT, SMP_USE_HRQHV },
|
{ "hdr_val", smp_fetch_hdr_val, ARG2(0,STR,SINT), val_hdr, SMP_T_SINT, SMP_USE_HRQHV },
|
||||||
|
Loading…
Reference in New Issue
Block a user