libs/sgi-uhttpd: fix binding to properly work with current uhttpd2 implementation
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
parent
0efb19876b
commit
c3bf59a91d
1 changed files with 4 additions and 20 deletions
|
@ -55,17 +55,7 @@ function handle_request(env)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local function send(...)
|
local send = uhttpd.send
|
||||||
return uhttpd.send(...)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function sendc(...)
|
|
||||||
if env.HTTP_VERSION > 1.0 then
|
|
||||||
return uhttpd.sendc(...)
|
|
||||||
else
|
|
||||||
return uhttpd.send(...)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local req = luci.http.Request(
|
local req = luci.http.Request(
|
||||||
renv, recv, luci.ltn12.sink.file(io.stderr)
|
renv, recv, luci.ltn12.sink.file(io.stderr)
|
||||||
|
@ -76,16 +66,11 @@ function handle_request(env)
|
||||||
local hcache = { }
|
local hcache = { }
|
||||||
local active = true
|
local active = true
|
||||||
|
|
||||||
if env.HTTP_VERSION > 1.0 then
|
|
||||||
hcache["Transfer-Encoding"] = "chunked"
|
|
||||||
end
|
|
||||||
|
|
||||||
while coroutine.status(x) ~= "dead" do
|
while coroutine.status(x) ~= "dead" do
|
||||||
local res, id, data1, data2 = coroutine.resume(x, req)
|
local res, id, data1, data2 = coroutine.resume(x, req)
|
||||||
|
|
||||||
if not res then
|
if not res then
|
||||||
send(env.SERVER_PROTOCOL)
|
send("Status: 500 Internal Server Error\r\n")
|
||||||
send(" 500 Internal Server Error\r\n")
|
|
||||||
send("Content-Type: text/plain\r\n\r\n")
|
send("Content-Type: text/plain\r\n\r\n")
|
||||||
send(tostring(id))
|
send(tostring(id))
|
||||||
break
|
break
|
||||||
|
@ -93,8 +78,7 @@ function handle_request(env)
|
||||||
|
|
||||||
if active then
|
if active then
|
||||||
if id == 1 then
|
if id == 1 then
|
||||||
send(env.SERVER_PROTOCOL)
|
send("Status: ")
|
||||||
send(" ")
|
|
||||||
send(tostring(data1))
|
send(tostring(data1))
|
||||||
send(" ")
|
send(" ")
|
||||||
send(tostring(data2))
|
send(tostring(data2))
|
||||||
|
@ -110,7 +94,7 @@ function handle_request(env)
|
||||||
end
|
end
|
||||||
send("\r\n")
|
send("\r\n")
|
||||||
elseif id == 4 then
|
elseif id == 4 then
|
||||||
sendc(tostring(data1 or ""))
|
send(tostring(data1 or ""))
|
||||||
elseif id == 5 then
|
elseif id == 5 then
|
||||||
active = false
|
active = false
|
||||||
elseif id == 6 then
|
elseif id == 6 then
|
||||||
|
|
Loading…
Reference in a new issue