Set method to POST if we have postdata and no other method is set

This commit is contained in:
Steven Barth 2009-03-02 19:45:07 +00:00
parent 62a914555e
commit eb64affa39

View file

@ -121,7 +121,6 @@ function request_raw(uri, options)
options.depth = options.depth or 10 options.depth = options.depth or 10
local headers = options.headers or {} local headers = options.headers or {}
local protocol = options.protocol or "HTTP/1.1" local protocol = options.protocol or "HTTP/1.1"
local method = options.method or "GET"
headers["User-Agent"] = headers["User-Agent"] or "LuCI httpclient 0.1" headers["User-Agent"] = headers["User-Agent"] or "LuCI httpclient 0.1"
if headers.Connection == nil then if headers.Connection == nil then
@ -158,10 +157,11 @@ function request_raw(uri, options)
headers["Content-Length"] = headers["Content-Length"] or #options.body headers["Content-Length"] = headers["Content-Length"] or #options.body
headers["Content-Type"] = headers["Content-Type"] or headers["Content-Type"] = headers["Content-Type"] or
"application/x-www-form-urlencoded" "application/x-www-form-urlencoded"
options.method = options.method or "POST"
end end
-- Assemble message -- Assemble message
local message = {method .. " " .. path .. " " .. protocol} local message = {(options.method or "GET") .. " " .. path .. " " .. protocol}
for k, v in pairs(headers) do for k, v in pairs(headers) do
if type(v) == "string" then if type(v) == "string" then