projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c30cf9a
)
send Cookie in a single header line, follow browser behavior
author
Yuzo
<hyzgog@gmail.com>
Thu, 22 Jan 2015 04:50:58 +0000
(12:50 +0800)
committer
Yuzo
<hyzgog@gmail.com>
Thu, 22 Jan 2015 04:50:58 +0000
(12:50 +0800)
libs/luci-lib-httpclient/luasrc/httpclient.lua
patch
|
blob
|
history
diff --git
a/libs/luci-lib-httpclient/luasrc/httpclient.lua
b/libs/luci-lib-httpclient/luasrc/httpclient.lua
index
c84a03b
..
af79695
100644
(file)
--- a/
libs/luci-lib-httpclient/luasrc/httpclient.lua
+++ b/
libs/luci-lib-httpclient/luasrc/httpclient.lua
@@
-176,20
+176,8
@@
function request_raw(uri, options)
options.method = options.method or "POST"
end
options.method = options.method or "POST"
end
- -- Assemble message
- local message = {(options.method or "GET") .. " " .. path .. " " .. protocol}
-
- for k, v in pairs(headers) do
- if type(v) == "string" or type(v) == "number" then
- message[#message+1] = k .. ": " .. v
- elseif type(v) == "table" then
- for i, j in ipairs(v) do
- message[#message+1] = k .. ": " .. j
- end
- end
- end
-
if options.cookies then
if options.cookies then
+ local cookiedata = {}
for _, c in ipairs(options.cookies) do
local cdo = c.flags.domain
local cpa = c.flags.path
for _, c in ipairs(options.cookies) do
local cdo = c.flags.domain
local cpa = c.flags.path
@@
-197,11
+185,29
@@
function request_raw(uri, options)
and (cpa == path or cpa == "/" or cpa .. "/" == path:sub(#cpa+1))
and (not c.flags.secure or pr == "https")
then
and (cpa == path or cpa == "/" or cpa .. "/" == path:sub(#cpa+1))
and (not c.flags.secure or pr == "https")
then
-
message[#message+1] = "Cookie: " ..
c.key .. "=" .. c.value
+
cookiedata[#cookiedata+1] =
c.key .. "=" .. c.value
end
end
end
end
+ if headers["Cookie"] then
+ headers["Cookie"] = headers["Cookie"] .. "; " .. table.concat(cookiedata, "; ")
+ else
+ headers["Cookie"] = table.concat(cookiedata, "; ")
+ end
end
end
+
+ -- Assemble message
+ local message = {(options.method or "GET") .. " " .. path .. " " .. protocol}
+ for k, v in pairs(headers) do
+ if type(v) == "string" or type(v) == "number" then
+ message[#message+1] = k .. ": " .. v
+ elseif type(v) == "table" then
+ for i, j in ipairs(v) do
+ message[#message+1] = k .. ": " .. j
+ end
+ end
+ end
+
message[#message+1] = ""
message[#message+1] = ""
message[#message+1] = ""
message[#message+1] = ""