BUG/MINOR: http-fetch: Fix smp_fetch_body() when called from a health-check
res.body may be called from a health-check. It is probably never used. But it is
possibe. In such case, there is no channel. Thus we must not use it
unconditionally to set the flag SMP_F_MAY_CHANGE on the smp.
Now the condition test the channel first. In addtion, the flag is not set if the
payload is fully received.
This patch must be backported as far as 2.2.
diff --git a/src/http_fetch.c b/src/http_fetch.c
index 595e0e3..a0b9cf5 100644
--- a/src/http_fetch.c
+++ b/src/http_fetch.c
@@ -587,6 +587,7 @@
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
struct buffer *temp;
int32_t pos;
+ int finished = 0;
if (!htx)
return 0;
@@ -596,8 +597,10 @@
struct htx_blk *blk = htx_get_blk(htx, pos);
enum htx_blk_type type = htx_get_blk_type(blk);
- if (type == HTX_BLK_EOM || type == HTX_BLK_TLR || type == HTX_BLK_EOT)
+ if (type == HTX_BLK_EOM || type == HTX_BLK_TLR || type == HTX_BLK_EOT) {
+ finished = 1;
break;
+ }
if (type == HTX_BLK_DATA) {
if (!h1_format_htx_data(htx_get_blk_value(htx, blk), temp, 0))
return 0;
@@ -608,7 +611,8 @@
smp->data.u.str = *temp;
smp->flags = SMP_F_VOL_TEST;
- if (!channel_full(chn, global.tune.maxrewrite) && !(chn->flags & (CF_EOI|CF_SHUTR|CF_READ_ERROR)))
+ if (!finished && (check || (chn && !channel_full(chn, global.tune.maxrewrite) &&
+ !(chn->flags & (CF_EOI|CF_SHUTR|CF_READ_ERROR)))))
smp->flags |= SMP_F_MAY_CHANGE;
return 1;