]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: lua: Return an error if a legacy HTTP applet doesn't send anything
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 18 Dec 2018 20:20:57 +0000 (21:20 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 19 Dec 2018 12:45:53 +0000 (13:45 +0100)
In legacy mode, if an HTTP applet does not send any response, an error 500 is
returned.

reg-tests/lua/b00003.vtc
src/hlua.c

index 3f06b90a34bd4fd102bbf8a12fb7e4bec3e5d21d..a1731b0f2c1682879936fbc7414ec83f6e4fe915 100644 (file)
@@ -19,7 +19,7 @@ feature ignore_unknown_macro
 
 syslog Slog -level info -repeat 100 {
     recv info
-    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Ta=[0-9]* Tc=[0-9]* Td=-1 Th=[0-9]* Ti=[0-9]* Tq=[0-9]* TR=[0-9] Tr=-1 Tt=[0-9]* Tw=[0-9]*"
+    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Ta=[0-9]* Tc=[0-9]* Td=[0-9]* Th=[0-9]* Ti=[0-9]* Tq=[0-9]* TR=[0-9] Tr=[0-9]* Tt=[0-9]* Tw=[0-9]*"
 } -start
 
 haproxy h1 -conf {
index 79b486da8eb6b6f31c3fef3923058ea0c23f9167..6efabeea1e43fc6235fc1325e0b4b0f9ca06c351 100644 (file)
@@ -4233,6 +4233,7 @@ __LJMP static int hlua_applet_htx_getline_yield(lua_State *L, int status, lua_KC
        htx = htx_from_buf(&req->buf);
        count = co_data(req);
        blk = htx_get_head_blk(htx);
+
        while (count && !stop && blk) {
                enum htx_blk_type type = htx_get_blk_type(blk);
                uint32_t sz = htx_get_blksz(blk);
@@ -7544,6 +7545,8 @@ static void hlua_applet_http_fct(struct appctx *ctx)
        }
 
        if (ctx->ctx.hlua_apphttp.flags & APPLET_DONE) {
+               if (!(ctx->ctx.hlua_apphttp.flags & APPLET_HDR_SENT))
+                       goto error;
 
                /* We must send the final chunk. */
                if (ctx->ctx.hlua_apphttp.flags & APPLET_CHUNKED &&