Fix. Lua-cURL/browser.lua example compatibility with lcurl.cURL
This commit is contained in:
parent
9f0cc95fa0
commit
c231e6bc25
@ -136,16 +136,16 @@ end
|
|||||||
--function helper for result
|
--function helper for result
|
||||||
--taken from luasocket page (MIT-License)
|
--taken from luasocket page (MIT-License)
|
||||||
local function build_w_cb(t)
|
local function build_w_cb(t)
|
||||||
return function(s,len)
|
return function(s)
|
||||||
table.insert(t, s)
|
table.insert(t, s)
|
||||||
return len,nil
|
return #s,nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--function helper for headers
|
--function helper for headers
|
||||||
--taken from luasocket page (MIT-License)
|
--taken from luasocket page (MIT-License)
|
||||||
local function h_build_w_cb(t)
|
local function h_build_w_cb(t)
|
||||||
return function(s,len)
|
return function(s)
|
||||||
--stores the received data in the table t
|
--stores the received data in the table t
|
||||||
--prepare header data
|
--prepare header data
|
||||||
name, value = s:match("(.-): (.+)")
|
name, value = s:match("(.-): (.+)")
|
||||||
@ -158,7 +158,7 @@ local function h_build_w_cb(t)
|
|||||||
t.codemessage = codemessage:gsub("[\n\r]", "")
|
t.codemessage = codemessage:gsub("[\n\r]", "")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return len,nil
|
return #s,nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -264,8 +264,3 @@ end
|
|||||||
-- print(resp.body)
|
-- print(resp.body)
|
||||||
-- table.foreach(resp.headers, print)
|
-- table.foreach(resp.headers, print)
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
b = browser:new()
|
|
||||||
resp = b:open("http://www.html-kit.com/tools/cookietester/")
|
|
||||||
print(resp.body)
|
|
||||||
table.foreach(resp.headers, print)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user