Toujours de gros problème de fuite mémoire avec le serveur web ;-(
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
-- petit script de serveur WEB avec Active Server Page ZYX
|
||||
|
||||
print("\n web_srv2.lua zf190126.1837 \n")
|
||||
print("\n web_srv2.lua zf190126.1844 \n")
|
||||
|
||||
-- send a file from memory to the client; max. line length = 1024 bytes!
|
||||
function send_file(zclient, zfilename)
|
||||
@@ -14,12 +14,17 @@ function send_file(zclient, zfilename)
|
||||
until not line
|
||||
file.close()
|
||||
else
|
||||
zclient:send("<html><h1>"..zfilename.." not found - 404 error.</h1><a href='index.html'>Home</a><br></html>")
|
||||
zclient:send("<html><h1>"..zfilename.." not found - 404 error.</h1><a href='/'>Home</a><br></html>")
|
||||
end
|
||||
zfilename = nil
|
||||
zclient = nil
|
||||
line = nil
|
||||
file = nil
|
||||
|
||||
end
|
||||
|
||||
|
||||
srv = net.createServer(net.TCP)
|
||||
srv = net.createServer(net.TCP,10)
|
||||
srv:listen(80, function(conn)
|
||||
conn:on("receive", function(client, request)
|
||||
_, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP")
|
||||
@@ -30,6 +35,7 @@ srv:listen(80, function(conn)
|
||||
print("path: ",path)
|
||||
print("vars: ",vars)
|
||||
|
||||
--[[
|
||||
if not string.find(request, "/favicon.ico") then
|
||||
print("coucou")
|
||||
if (method == nil) then
|
||||
@@ -44,11 +50,25 @@ srv:listen(80, function(conn)
|
||||
end
|
||||
file_html=string.gsub(path, "/", "")
|
||||
print("file_html: ",file_html)
|
||||
send_file(conn, file_html)
|
||||
-- send_file(conn, file_html)
|
||||
-- send_file = nil
|
||||
|
||||
]]
|
||||
|
||||
|
||||
conn:send("<h1> ESP8266<BR>Server is working!</h1>\n\n")
|
||||
file_html = nil
|
||||
k = nil
|
||||
v = nil
|
||||
_GET = nil
|
||||
method = nil
|
||||
path = nil
|
||||
vars = nil
|
||||
|
||||
-- conn:send("<h1> ESP8266<BR>Server is working!</h1>\n\n")
|
||||
|
||||
end
|
||||
-- end
|
||||
|
||||
|
||||
end)
|
||||
conn:on("sent", function(c) c:close() end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user