From 3336ec377553f5a0fba72f55bda0a11f74e5df57 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Fri, 27 Nov 2026 15:59:38 +0000 Subject: [PATCH 1/2] * modules/lua/lua_request.c (lua_websocket_greet): Close the connection after the request once upgraded. Co-Authored-By: Claude Fable 5.2 --- modules/lua/lua_request.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/lua/lua_request.c b/modules/lua/lua_request.c index 19599b5e655..7d5a3eb5101 100644 --- a/modules/lua/lua_request.c +++ b/modules/lua/lua_request.c @@ -2387,6 +2387,9 @@ static int lua_websocket_greet(lua_State *L) r->bytes_sent = 0; r->read_chunked = 0; ap_rflush(r); + /* The connection cannot go back to HTTP after the upgrade, + * however the script ends. */ + r->connection->keepalive = AP_CONN_CLOSE; ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(03012) "Websocket: Upgraded from HTTP to Websocket"); lua_pushboolean(L, 1); From 39f81254d656bfbd7e0acb5f4a81a79bafeeb0a7 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Fri, 27 Nov 2026 16:20:15 +0000 Subject: [PATCH 2/2] * modules/lua/lua_request.c (lua_ap_sendfile): Send nothing for an empty file. Co-Authored-By: Claude Fable 5.2 --- modules/lua/lua_request.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/lua/lua_request.c b/modules/lua/lua_request.c index 7d5a3eb5101..b534c6bf705 100644 --- a/modules/lua/lua_request.c +++ b/modules/lua/lua_request.c @@ -945,7 +945,13 @@ static int lua_ap_sendfile(lua_State *L) apr_file_t *file; rc = apr_file_open(&file, filename, APR_READ, APR_OS_DEFAULT, p); - if (rc == APR_SUCCESS) { + if (rc == APR_SUCCESS && file_info.size == 0) { + /* Nothing to send; an empty file bucket could be held by + * the core output filter until the end of the request. */ + apr_file_close(file); + lua_pushinteger(L, 0); + } + else if (rc == APR_SUCCESS) { apr_bucket_brigade *bb; /* As ap_send_fd(), but with the brigade in the call pool.