This commit is contained in:
parent
4776545a41
commit
59e0218a72
@ -83,7 +83,7 @@ return function (port)
|
|||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
if fileExists then
|
if fileExists then
|
||||||
print("gzip variant exists, serving that one")
|
--print("gzip variant exists, serving that one")
|
||||||
uri.file = uri.file .. ".gz"
|
uri.file = uri.file .. ".gz"
|
||||||
uri.isGzipped = true
|
uri.isGzipped = true
|
||||||
end
|
end
|
||||||
@ -113,6 +113,22 @@ return function (port)
|
|||||||
local auth
|
local auth
|
||||||
local user = "Anonymous"
|
local user = "Anonymous"
|
||||||
|
|
||||||
|
-- as suggest by anyn99 (https://github.com/marcoskirsch/nodemcu-httpserver/issues/36#issuecomment-167442461)
|
||||||
|
-- Some browsers send the POST data in multiple chunks.
|
||||||
|
-- Collect data packets until the size of HTTP body meets the Content-Length stated in header
|
||||||
|
if payload:find("Content%-Length:") or bBodyMissing then
|
||||||
|
if fullPayload then fullPayload = fullPayload .. payload else fullPayload = payload end
|
||||||
|
if (tonumber(string.match(fullPayload, "%d+", fullPayload:find("Content%-Length:")+16)) > #fullPayload:sub(fullPayload:find("\r\n\r\n", 1, true)+4, #fullPayload)) then
|
||||||
|
bBodyMissing = true
|
||||||
|
return
|
||||||
|
else
|
||||||
|
--print("HTTP packet assembled! size: "..#fullPayload)
|
||||||
|
payload = fullPayload
|
||||||
|
fullPayload, bBodyMissing = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
collectgarbage()
|
||||||
|
|
||||||
-- parse payload and decide what to serve.
|
-- parse payload and decide what to serve.
|
||||||
local req = dofile("httpserver-request.lc")(payload)
|
local req = dofile("httpserver-request.lc")(payload)
|
||||||
print("Requested URI: " .. req.request)
|
print("Requested URI: " .. req.request)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user