summaryrefslogtreecommitdiffhomepage
path: root/libs/lucid-http/luasrc/lucid
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2009-07-25 07:27:05 +0000
committerSteven Barth <steven@midlink.org>2009-07-25 07:27:05 +0000
commitb8ab3b9dacab9c6d4344c60fdb4046087a24f233 (patch)
tree2d374430d2ef1919336061f3d5481e732f01d7ae /libs/lucid-http/luasrc/lucid
parent3194662054cebfefc48c7ff3d3a5d7a3aa988b9a (diff)
Add: luci.http.splice to allow direct copying of data from a file
descriptor
Diffstat (limited to 'libs/lucid-http/luasrc/lucid')
-rw-r--r--libs/lucid-http/luasrc/lucid/http/server.lua13
1 files changed, 10 insertions, 3 deletions
diff --git a/libs/lucid-http/luasrc/lucid/http/server.lua b/libs/lucid-http/luasrc/lucid/http/server.lua
index 00c6b84161..0fe9473166 100644
--- a/libs/lucid-http/luasrc/lucid/http/server.lua
+++ b/libs/lucid-http/luasrc/lucid/http/server.lua
@@ -510,7 +510,7 @@ function Server.process(self, client, env)
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)
@@ -554,8 +554,15 @@ function Server.process(self, client, env)
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