summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/server.lua b/server.lua
index 9fe4f5e..6be07da 100644
--- a/server.lua
+++ b/server.lua
@@ -40,11 +40,14 @@ return function(env)
end
local data
- if env.CONTENT_LENGTH then
+ local length = env.CONTENT_LENGTH and tonumber(
+ env.CONTENT_LENGTH
+ ) or 0
+ if length > 0 then
local success
success, data = pcall(
json.decode,
- env.input:read(env.CONTENT_LENGTH)
+ env.input:read(length)
)
if not success then
return wrap(400, nil, 'Request not in JSON format')