Skip to content

Commit 2e47e3a

Browse files
committed
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.
1 parent 462f522 commit 2e47e3a

5 files changed

Lines changed: 12 additions & 7 deletions

File tree

include/haproxy/htx.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
#include <haproxy/http-t.h>
3131
#include <haproxy/htx-t.h>
3232

33+
/* ->extra field value when the payload lenght is unknown (non-chunked message
34+
* with no "Content-length" header)
35+
*/
36+
#define HTX_UNKOWN_PAYLOAD_LENGTH ULLONG_MAX
37+
3338
extern struct htx htx_empty;
3439

3540
struct htx_blk *htx_defrag(struct htx *htx, struct htx_blk *blk, uint32_t info);

src/h1_htx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ static int h1_postparse_req_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx
208208
}
209209

210210
/* If body length cannot be determined, set htx->extra to
211-
* ULLONG_MAX. This value is impossible in other cases.
211+
* HTX_UNKOWN_PAYLOAD_LENGTH. This value is impossible in other cases.
212212
*/
213-
htx->extra = ((h1m->flags & H1_MF_XFER_LEN) ? h1m->curr_len : ULLONG_MAX);
213+
htx->extra = ((h1m->flags & H1_MF_XFER_LEN) ? h1m->curr_len : HTX_UNKOWN_PAYLOAD_LENGTH);
214214

215215
end:
216216
return 1;
@@ -306,9 +306,9 @@ static int h1_postparse_res_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx
306306
sl->info.res.status = code;
307307

308308
/* If body length cannot be determined, set htx->extra to
309-
* ULLONG_MAX. This value is impossible in other cases.
309+
* HTX_UNKOWN_PAYLOAD_LENGTH. This value is impossible in other cases.
310310
*/
311-
htx->extra = ((h1m->flags & H1_MF_XFER_LEN) ? h1m->curr_len : ULLONG_MAX);
311+
htx->extra = ((h1m->flags & H1_MF_XFER_LEN) ? h1m->curr_len : HTX_UNKOWN_PAYLOAD_LENGTH);
312312

313313
end:
314314
return 1;

src/hlua.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4890,7 +4890,7 @@ static int hlua_applet_http_new(lua_State *L, struct appctx *ctx)
48904890
if (type == HTX_BLK_DATA)
48914891
len += htx_get_blksz(blk);
48924892
}
4893-
if (htx->extra != ULLONG_MAX)
4893+
if (htx->extra != HTX_UNKOWN_PAYLOAD_LENGTH)
48944894
len += htx->extra;
48954895

48964896
/* Stores the request path. */

src/http_fetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ static int smp_fetch_body_size(const struct arg *args, struct sample *smp, const
679679
if (type == HTX_BLK_DATA)
680680
len += htx_get_blksz(blk);
681681
}
682-
if (htx->extra != ULLONG_MAX)
682+
if (htx->extra != HTX_UNKOWN_PAYLOAD_LENGTH)
683683
len += htx->extra;
684684

685685
smp->data.type = SMP_T_SINT;

src/mux_h2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6356,7 +6356,7 @@ static size_t h2_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, in
63566356
if (!(h2s->flags & H2_SF_OUTGOING_DATA) && count)
63576357
h2s->flags |= H2_SF_OUTGOING_DATA;
63586358

6359-
if (htx->extra && htx->extra != ULLONG_MAX)
6359+
if (htx->extra && htx->extra != HTX_UNKOWN_PAYLOAD_LENGTH)
63606360
h2s->flags |= H2_SF_MORE_HTX_DATA;
63616361
else
63626362
h2s->flags &= ~H2_SF_MORE_HTX_DATA;

0 commit comments

Comments
 (0)