forked from marcoskirsch/nodemcu-httpserver
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpserver-error.lua
More file actions
Latest commit
19 lines (16 loc) · 934 Bytes
/
Copy pathhttpserver-error.lua
File metadata and controls
19 lines (16 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- httpserver-error.lua
-- Part of nodemcu-httpserver, handles sending error pages to client.
-- Author: Marcos Kirsch
returnfunction (connection, req, args)
localfunctionsendHeader(connection, code, errorString, extraHeaders, mimeType)
connection:send("HTTP/1.0 " ..code.."" ..errorString.."\r\nServer: nodemcu-httpserver\r\nContent-Type: " ..mimeType.."\r\n")
fori, headerinipairs(extraHeaders) do
connection:send(header.."\r\n")
end
connection:send("connection: close\r\n\r\n")
end
print("Error " ..args.code..": " ..args.errorString)
args.headers=args.headersor {}
sendHeader(connection, args.code, args.errorString, args.headers, "text/html")
connection:send("<html><head><title>" ..args.code.." - " ..args.errorString.."</title></head><body><h1>" ..args.code.." - " ..args.errorString.."</h1></body></html>\r\n")
end