From fe24757d5207309429c1b212b33d49d72429b6af Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Fri, 26 Apr 2013 13:29:40 +0300 Subject: deal with requests with zero Content-Length --- server.lua | 7 +++++-- 1 file 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') -- cgit v1.2.3