A Set-Cookie header contains a single cookie, and other elements on
the same line are not cookies but attributes (which can easily be
mistaken for them by a parser). That's what happens for res.cook_cnt()
which uses the same parser as req.cook_cnt() and counts apparent cookie
values without figuring it's parsing attributes. Let's just do like for
res.cookie_names() and check for a request or response before looping,
so that we can now count a single cookie per set-cookie response.
This can be backported to all stable versions.
char *val_beg, *val_end;
char *cook = NULL;
size_t cook_l = 0;
+ int is_req = !(check || (chn && chn->flags & CF_ISRESP));
int cnt;
if (args->type == ARGT_STR){
if (!htx)
return 0;
- hdr = (!(check || (chn && chn->flags & CF_ISRESP)) ? ist("Cookie") : ist("Set-Cookie"));
+ hdr = (is_req ? ist("Cookie") : ist("Set-Cookie"));
val_end = val_beg = NULL;
ctx.blk = NULL;
&smp->data.u.str.area,
&smp->data.u.str.data))) {
cnt++;
+ if (!is_req) {
+ /* there's a single cookie per set-cookie header */
+ val_beg = NULL;
+ break;
+ }
}
}