diff --git a/modules/lua/lua_request.c b/modules/lua/lua_request.c index 19599b5e655..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. @@ -2387,6 +2393,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);