]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx: Add an HTX value for the extra field is payload length is unknown
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 13 Jan 2023 10:40:24 +0000 (11:40 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 13 Jan 2023 10:51:11 +0000 (11:51 +0100)
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.

include/haproxy/htx.h
src/h1_htx.c
src/hlua.c
src/http_fetch.c
src/mux_h2.c

index 0fd1a1b9723d7bfcac318fabeb63a97277eb3937..339f0a559e84045c95835d504b9129d6c5172894 100644 (file)
 #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);
index 1b79584a3f4c8ea800ca6df36e67d1493a70c96c..5e7f1ad5e89ba56fc9f1f0ea7fd1c40c6a4874af 100644 (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;
index e5c6c93b67bdfa0d6e77fda6a8e77403eb1d44b9..34672267537fa3de262f5f8380633058c0f48872 100644 (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. */
index 27cfe54732c453df64df21749167af4f1b05b4f9..8c01e034343a8cb930433b17f688361e0d5177f0 100644 (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;
index 4c29a281525221939d1200ca9f157f7cf770072c..ffbde461936709cbd197c0363bd88b1ecf35aced 100644 (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;