X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fluci-base%2Fluasrc%2Fhttp.lua;h=f4ede4b8a5771ea3b7eacb301993f09d1ddee912;hp=be5577ee0932931b207b9b7f694cb391a6c52799;hb=9ed48ef2a62df5406c589ef9a43da51df8d9645c;hpb=914c661b58fc7e2dede1b9b4f83544b05232065c diff --git a/modules/luci-base/luasrc/http.lua b/modules/luci-base/luasrc/http.lua index be5577ee0..f4ede4b8a 100644 --- a/modules/luci-base/luasrc/http.lua +++ b/modules/luci-base/luasrc/http.lua @@ -14,7 +14,7 @@ local table, ipairs, pairs, type, tostring, tonumber, error = module "luci.http" -HTTP_MAX_CONTENT = 1024*8 -- 8 kB maximum content size +HTTP_MAX_CONTENT = 1024*100 -- 100 kB maximum content size context = util.threadlocal() @@ -416,7 +416,7 @@ function mimedecode_message_body(src, msg, file_cb) end return true - end) + end, HTTP_MAX_CONTENT) return ltn12.pump.all(src, function (chunk) len = len + (chunk and #chunk or 0) @@ -460,7 +460,7 @@ function urldecode_message_body(src, msg) end return true - end) + end, HTTP_MAX_CONTENT) return ltn12.pump.all(src, function (chunk) len = len + (chunk and #chunk or 0) @@ -486,26 +486,22 @@ end -- handled then the whole message body will be stored unaltered as "content" -- property within the given message object. function parse_message_body(src, msg, filecb) - local ctype = lhttp.header_attribute(msg.env.CONTENT_TYPE, nil) - - -- Is it multipart/mime ? - if msg.env.REQUEST_METHOD == "POST" and - ctype == "multipart/form-data" - then - return mimedecode_message_body(src, msg, filecb) + if msg.env.CONTENT_LENGTH or msg.env.REQUEST_METHOD == "POST" then + local ctype = lhttp.header_attribute(msg.env.CONTENT_TYPE, nil) - -- Is it application/x-www-form-urlencoded ? - elseif msg.env.REQUEST_METHOD == "POST" and - ctype == "application/x-www-form-urlencoded" - then - return urldecode_message_body(src, msg) + -- Is it multipart/mime ? + if ctype == "multipart/form-data" then + return mimedecode_message_body(src, msg, filecb) + -- Is it application/x-www-form-urlencoded ? + elseif ctype == "application/x-www-form-urlencoded" then + return urldecode_message_body(src, msg) - -- Unhandled encoding - -- If a file callback is given then feed it chunk by chunk, else - -- store whole buffer in message.content - else + end + -- Unhandled encoding + -- If a file callback is given then feed it chunk by chunk, else + -- store whole buffer in message.content local sink -- If we have a file callback then feed it @@ -553,4 +549,6 @@ function parse_message_body(src, msg, filecb) return true end + + return false end