Patching CGILua to handle text/plain
JSON RPC (both the JSONRPC4Lua implementation and the jsolait Javascript implementation) send the http request with a Content-Type of application/json-rpc.

CGILua does not accept application/json-rpc content, and will generate 'Unsupported Media Type' error.

This is easily patched in CGILua by making the following change to cgilua/post.lua, line 289:

Change:

   elseif strfind (contenttype, "application/xml", 1, true) or strfind (contenttype, "text/xml", 1, true) or strfind (contenttype, "text/plain", 1, true) then
     tinsert (defs.args, read (inputsize))
   else
     error("Unsupported Media Type: "..contenttype)
to
   else
     local input = read(inputsize)
     tinsert (defs.args, input)
This makes CGILua handle all unsupported content types as text/plain, without parsing the incoming POST data.

Please note: I have requested the maintainers of CGILua to make this change to CGILua, whereafter this patch will no longer be required.