luci-lib-base: ensure that `luci.http` can be required standalone
authorJo-Philipp Wich <jo@mein.io>
Fri, 4 Nov 2022 15:06:18 +0000 (16:06 +0100)
committerJo-Philipp Wich <jo@mein.io>
Fri, 4 Nov 2022 15:10:12 +0000 (16:10 +0100)
Various existing Lua software is requiring the `luci.http` library for
URL encoding/decoding tasks so ensure that it can be loaded in a stand
alone manner even if the emulated Lua runtime environment is not
available.

Fixes: cea2c3578e ("luci-lib-base: forward luci.http.context.request.message to ucode")
Ref: https://forum.openwrt.org/t/x/141817
Ref: https://github.com/openwrt/luci/pull/5976#issuecomment-1296220586
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libs/luci-lib-base/luasrc/http.lua

index 3b0865082d3f178083056781e172c45a5598e432..882b71c8f7fc4c92a1e51201aa7f5923f7396c3f 100644 (file)
@@ -140,6 +140,6 @@ context = {
                content        = function(self, ...) return content(...)        end;
                getcookie      = function(self, ...) return getcookie(...)      end;
                setfilehandler = function(self, ...) return setfilehandler(...) end;
-               message        = L.http.message
+               message        = L and L.http.message
        }
 }