self._output, self._input = nil, nil
self:_error(err)
else
- do_read()
line = tostring(line)
if line == "OK" or line:match("^ACK ") then
local success = line == "OK"
else
local _, _, key, value = string.find(line, "([^:]+):%s(.+)")
if key then
- self._pending_reply[string.lower(key)] = value
+ if key == "binary" then
+ value = tonumber(value)
+ local data = {}
+ while value > 0 do
+ local b = assert(obj:read_bytes(value))
+ table.insert(data, b.data)
+ value = value - #b
+ end
+ local w = obj:read_bytes(1) -- read newline at end of binary
+ self._pending_reply[string.lower(key)] = table.concat(data)
+ else
+ self._pending_reply[string.lower(key)] = value
+ end
end
end
+ do_read()
end
end)
end