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")
22 Luci = luci.util.class(luci.httpd.module.Handler)
23 Response = luci.httpd.module.Response
25 function Luci.__init__(self)
26 luci.httpd.module.Handler.__init__(self)
29 function Luci.handle_head(self, ...)
30 local response, sourceout = self:handle_get(...)
34 function Luci.handle_post(self, ...)
35 return self:handle_get(...)
38 function Luci.handle_get(self, request, sourcein, sinkerr)
39 local r = luci.http.Request(
45 local res, id, data1, data2 = true, 0, nil, nil
49 local x = coroutine.create(luci.dispatcher.httpdispatch)
50 while not id or id < 3 do
53 res, id, data1, data2 = coroutine.resume(x, r)
57 headers["Content-Type"] = "text/plain"
59 return Response( status, headers ), function() return table.remove(err) end
65 headers[data1] = data2
70 local res, id, data = coroutine.resume(x)
82 return Response(status, headers), iter