]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: hlua: Use flags of HTX blocks to detect EOM from an HTTP applet 20260615-htx-flags
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 21 Jul 2026 09:58:22 +0000 (11:58 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 24 Jul 2026 10:20:47 +0000 (12:20 +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 30fc07b28281a619cbb7a926804de0848421049a..8d8f36f825e937b86e6099d45114aea887fc9e07 100644 (file)
@@ -5838,6 +5838,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;
 
@@ -5845,22 +5846,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:
@@ -5934,6 +5932,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;
 
@@ -5941,22 +5940,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);