]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: hlua: Use flags of HTX blocks to detect EOM from an HTTP applet
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 21 Jul 2026 09:58:22 +0000 (11:58 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 18 Sep 2026 15:05:18 +0000 (17:05 +0200)
When we try to get request's data from an HTTP applet, instead of testing
HTX_FL_HAS_EOM flag on the message, we now rely on the flags of HTX blocks.
The logic remains the same, when all DATA blocks were consumed, we consider
the request as fully received. It may be when the blocks with the EOM flag
was removed or because a trailer was seen.

src/hlua.c

index 92663a1a455ad1bb752037c9387ffb79ab7c4f8a..b9c7beaaada4c30d8811d0a74098da26426aa731 100644 (file)
@@ -5850,6 +5850,7 @@ __LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_K
 
                        case HTX_BLK_TLR:
                        case HTX_BLK_EOT:
+                               http_ctx->flags |= APPLET_REQ_RECV;
                                stop = 1;
                                break;
 
@@ -5857,22 +5858,19 @@ __LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_K
                                break;
                }
 
-               if (sz == vlen)
+               if (sz == vlen) {
+                       if (blk->flags & HTX_BLK_FL_EOM) {
+                               http_ctx->flags |= APPLET_REQ_RECV;
+                               stop = 1;
+                       }
                        blk = htx_remove_blk(htx, blk);
+               }
                else {
                        htx_cut_data_blk(htx, blk, vlen);
                        break;
                }
        }
 
-       /* The message was fully consumed and no more data are expected
-        * (EOM flag set).
-        */
-       if (htx_is_empty(htx) && (htx->flags & HTX_FL_HAS_EOM)) {
-               http_ctx->flags |= APPLET_REQ_RECV;
-               stop = 1;
-       }
-
        htx_to_buf(htx, inbuf);
        if (!stop) {
          wait:
@@ -5946,6 +5944,7 @@ __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KCon
 
                        case HTX_BLK_TLR:
                        case HTX_BLK_EOT:
+                               http_ctx->flags |= APPLET_REQ_RECV;
                                len = 0;
                                break;
 
@@ -5953,22 +5952,19 @@ __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KCon
                                break;
                }
 
-               if (sz == vlen)
+               if (sz == vlen) {
+                       if (blk->flags & HTX_BLK_FL_EOM) {
+                               http_ctx->flags |= APPLET_REQ_RECV;
+                               len = 0;
+                       }
                        blk = htx_remove_blk(htx, blk);
+               }
                else {
                        htx_cut_data_blk(htx, blk, vlen);
                        break;
                }
        }
 
-       /* The message was fully consumed and no more data are expected
-        * (EOM flag set).
-        */
-       if (htx_is_empty(htx) && (htx->flags & HTX_FL_HAS_EOM)) {
-               http_ctx->flags |= APPLET_REQ_RECV;
-               len = 0;
-       }
-
        htx_to_buf(htx, inbuf);
        applet_fl_clr(luactx->appctx, APPCTX_FL_INBLK_FULL);