2 LuCI - SGI-Module for WSAPI
5 Server Gateway Interface for WSAPI
11 Copyright 2008 Steven Barth <steven@midlink.org>
13 Licensed under the Apache License, Version 2.0 (the "License");
14 you may not use this file except in compliance with the License.
15 You may obtain a copy of the License at
17 http://www.apache.org/licenses/LICENSE-2.0
19 Unless required by applicable law or agreed to in writing, software
20 distributed under the License is distributed on an "AS IS" BASIS,
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 See the License for the specific language governing permissions and
23 limitations under the License.
26 module("luci.sgi.wsapi", package.seeall)
27 local ltn12 = require("luci.ltn12")
29 require("luci.dispatcher")
30 require("luci.http.protocol")
32 function run(wsapi_env)
33 local r = luci.http.Request(
35 ltn12.source.file(wsapi_env.input),
36 ltn12.sink.file(wsapi_env.error)
39 local res, id, data1, data2 = true, 0, nil, nil
43 local x = coroutine.create(luci.dispatcher.httpdispatch)
47 res, id, data1, data2 = coroutine.resume(x, r)
51 headers["Content-Type"] = "text/plain"
53 return status, headers, function() local x = table.remove(err) return x end
59 headers[data1] = data2
64 local res, id, data = coroutine.resume(x)
65 if id == 4 and active then
73 if coroutine.status(x) == "dead" then
78 return status, headers, iter