headers["Content-Length"] = sourceout.len
end
end
- if not headers["Content-Length"] then
+ if not headers["Content-Length"] and not close then
if message.env.SERVER_PROTOCOL == "HTTP/1.1" then
headers["Transfer-Encoding"] = "chunked"
sinkout = chunksink(client)
if sourceout and stat then
if util.instanceof(sourceout, IOResource) then
- stat, code, msg = sourceout.fd:copyz(client, sourceout.len)
- else
+ if not headers["Transfer-Encoding"] then
+ stat, code, msg = sourceout.fd:copyz(client, sourceout.len)
+ sourceout = nil
+ else
+ sourceout = sourceout.fd:blocksource(nil, sourceout.len)
+ end
+ end
+
+ if sourceout then
stat, msg = ltn12.pump.all(sourceout, sinkout)
end
end
]]--
module("luci.sgi.cgi", package.seeall)
local ltn12 = require("luci.ltn12")
+require("nixio.util")
require("luci.http")
require("luci.sys")
require("luci.dispatcher")
io.flush()
io.close()
active = false
+ elseif id == 6 then
+ data1:copyz(nixio.stdout, data2)
end
end
end
end
end
+--- Splice data from a filedescriptor to the client.
+-- @param fp File descriptor
+-- @param size Bytes to splice (optional)
+function splice(fd, size)
+ coroutine.yield(6, fd, size)
+end
+
--- Redirects the client to a new URL and closes the connection.
-- @param url Target URL
function redirect(url)