From: Christopher Faulet Date: Fri, 13 Jan 2023 10:40:24 +0000 (+0100) Subject: MINOR: htx: Add an HTX value for the extra field is payload length is unknown X-Git-Tag: v2.8-dev2~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e47e3a1cf0e6a325d7b38fd98b5b884b06628f2;p=thirdparty%2Fhaproxy.git MINOR: htx: Add an HTX value for the extra field is payload length is unknown When the payload length cannot be determined, the htx extra field is set to the magical vlaue ULLONG_MAX. It is not obvious. This a dedicated HTX value is now used. Now, HTX_UNKOWN_PAYLOAD_LENGTH must be used in this case, instead of ULLONG_MAX. --- diff --git a/include/haproxy/htx.h b/include/haproxy/htx.h index 0fd1a1b972..339f0a559e 100644 --- a/include/haproxy/htx.h +++ b/include/haproxy/htx.h @@ -30,6 +30,11 @@ #include #include +/* ->extra field value when the payload lenght is unknown (non-chunked message + * with no "Content-length" header) + */ +#define HTX_UNKOWN_PAYLOAD_LENGTH ULLONG_MAX + extern struct htx htx_empty; struct htx_blk *htx_defrag(struct htx *htx, struct htx_blk *blk, uint32_t info); diff --git a/src/h1_htx.c b/src/h1_htx.c index 1b79584a3f..5e7f1ad5e8 100644 --- a/src/h1_htx.c +++ b/src/h1_htx.c @@ -208,9 +208,9 @@ static int h1_postparse_req_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx } /* If body length cannot be determined, set htx->extra to - * ULLONG_MAX. This value is impossible in other cases. + * HTX_UNKOWN_PAYLOAD_LENGTH. This value is impossible in other cases. */ - htx->extra = ((h1m->flags & H1_MF_XFER_LEN) ? h1m->curr_len : ULLONG_MAX); + htx->extra = ((h1m->flags & H1_MF_XFER_LEN) ? h1m->curr_len : HTX_UNKOWN_PAYLOAD_LENGTH); end: return 1; @@ -306,9 +306,9 @@ static int h1_postparse_res_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx sl->info.res.status = code; /* If body length cannot be determined, set htx->extra to - * ULLONG_MAX. This value is impossible in other cases. + * HTX_UNKOWN_PAYLOAD_LENGTH. This value is impossible in other cases. */ - htx->extra = ((h1m->flags & H1_MF_XFER_LEN) ? h1m->curr_len : ULLONG_MAX); + htx->extra = ((h1m->flags & H1_MF_XFER_LEN) ? h1m->curr_len : HTX_UNKOWN_PAYLOAD_LENGTH); end: return 1; diff --git a/src/hlua.c b/src/hlua.c index e5c6c93b67..3467226753 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -4890,7 +4890,7 @@ static int hlua_applet_http_new(lua_State *L, struct appctx *ctx) if (type == HTX_BLK_DATA) len += htx_get_blksz(blk); } - if (htx->extra != ULLONG_MAX) + if (htx->extra != HTX_UNKOWN_PAYLOAD_LENGTH) len += htx->extra; /* Stores the request path. */ diff --git a/src/http_fetch.c b/src/http_fetch.c index 27cfe54732..8c01e03434 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -679,7 +679,7 @@ static int smp_fetch_body_size(const struct arg *args, struct sample *smp, const if (type == HTX_BLK_DATA) len += htx_get_blksz(blk); } - if (htx->extra != ULLONG_MAX) + if (htx->extra != HTX_UNKOWN_PAYLOAD_LENGTH) len += htx->extra; smp->data.type = SMP_T_SINT; diff --git a/src/mux_h2.c b/src/mux_h2.c index 4c29a28152..ffbde46193 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -6356,7 +6356,7 @@ static size_t h2_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, in if (!(h2s->flags & H2_SF_OUTGOING_DATA) && count) h2s->flags |= H2_SF_OUTGOING_DATA; - if (htx->extra && htx->extra != ULLONG_MAX) + if (htx->extra && htx->extra != HTX_UNKOWN_PAYLOAD_LENGTH) h2s->flags |= H2_SF_MORE_HTX_DATA; else h2s->flags &= ~H2_SF_MORE_HTX_DATA;