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.
This commit is contained in:
Christopher Faulet 2023-01-13 11:40:24 +01:00
parent 462f52260c
commit 2e47e3a1cf
5 changed files with 12 additions and 7 deletions

View File

@ -30,6 +30,11 @@
#include <haproxy/http-t.h>
#include <haproxy/htx-t.h>
/* ->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);

View File

@ -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;

View File

@ -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. */

View File

@ -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;

View File

@ -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;