require("luci.dispatcher")
require("luci.http")
require("luci.http.protocol.date")
-require("ltn12")
+local ltn12 = require("luci.ltn12")
Luci = luci.util.class(luci.httpd.module.Handler)
Response = luci.httpd.module.Response
-function Luci.__init__(self)
+function Luci.__init__(self, limit)
luci.httpd.module.Handler.__init__(self)
+ self.limit = limit or 5
+ self.running = {}
+ setmetatable(self.running, {__mode = "k"})
end
function Luci.handle_head(self, ...)
local res, id, data1, data2 = true, 0, nil, nil
local headers = {}
local status = 200
+ local active = true
local x = coroutine.create(luci.dispatcher.httpdispatch)
while not id or id < 3 do
headers[data1] = data2
end
end
-<<<<<<< HEAD:libs/httpd/luasrc/httpd/handler/luci.lua
-=======
-
-
->>>>>>> * libs/httpd: Added Cache-Control header to LuCI:libs/httpd/luasrc/httpd/handler/luci.lua
local function iter()
local res, id, data = coroutine.resume(x)
if not res then
return nil, id
- elseif not id then
+ elseif not id or not active then
return true
elseif id == 5 then
+ active = false
+
+ while (coroutine.resume(x)) do
+ end
+
return nil
- else
+ elseif id == 4 then
return data
end
+ if coroutine.status(x) == "dead" then
+ return nil
+ end
end
- headers["Expires"] = luci.http.protocol.date.to_http( os.time() )
- headers["Date"] = headers["Expires"]
- headers["Cache-Control"] = "no-cache"
-
return Response(status, headers), iter
end