3 HTTP server implementation for LuCI - luci handler
4 (c) 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
16 module("luci.httpd.handler.luci", package.seeall)
18 require("luci.dispatcher")
20 require("luci.http.protocol.date")
23 Luci = luci.util.class(luci.httpd.module.Handler)
24 Response = luci.httpd.module.Response
26 function Luci.__init__(self)
27 luci.httpd.module.Handler.__init__(self)
30 function Luci.handle_head(self, ...)
31 local response, sourceout = self:handle_get(...)
35 function Luci.handle_post(self, ...)
36 return self:handle_get(...)
39 function Luci.handle_get(self, request, sourcein, sinkerr)
40 local r = luci.http.Request(
46 local res, id, data1, data2 = true, 0, nil, nil
50 local x = coroutine.create(luci.dispatcher.httpdispatch)
51 while not id or id < 3 do
54 res, id, data1, data2 = coroutine.resume(x, r)
58 headers["Content-Type"] = "text/plain"
60 return Response( status, headers ), function() return table.remove(err) end
66 headers[data1] = data2
71 local res, id, data = coroutine.resume(x)
83 headers["Expires"] = luci.http.protocol.date.to_http( os.time() )
84 headers["Date"] = headers["Expires"]
86 return Response(status, headers), iter