Skip to content

Commit 6ee9c8f

Browse files
committed
Add. Lua-cURL multi iterator returns also response row.
```Lua for d, t in m:perform() do if t == 'response' and d == 200 then ... end end ```
1 parent f2ab8ee commit 6ee9c8f

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/lua/cURL.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,19 @@ local remove_handle = wrap_function("remove_handle")
221221
local function make_iterator(self)
222222
local curl = require "lcurl.safe"
223223

224-
local buffers = {_ = {}} do
224+
local buffers = {resp = {}, _ = {}} do
225225

226226
function buffers:append(e, ...)
227-
if not self._[e] then
228-
self._[e] = {
229-
-- {"response", e:getinfo_response_code()}
230-
}
231-
end
227+
local resp = assert(e:getinfo_response_code())
228+
if not self._[e] then self._[e] = {} end
229+
232230
local b = self._[e]
231+
232+
if self.resp[e] ~= resp then
233+
b[#b + 1] = {"response", resp}
234+
self.resp[e] = resp
235+
end
236+
233237
b[#b + 1] = {...}
234238
end
235239

0 commit comments

Comments
 (0)