Use gzipped file if exists
If foo.html is requested and not found, foo.html.gz is checked and if exists, will served.
This commit is contained in:
parent
1d3cdaf1a7
commit
13e2bfbe9c
@ -23,8 +23,21 @@ return function (port)
|
|||||||
fileServeFunction = dofile("httpserver-error.lc")
|
fileServeFunction = dofile("httpserver-error.lc")
|
||||||
else
|
else
|
||||||
local fileExists = file.open(uri.file, "r")
|
local fileExists = file.open(uri.file, "r")
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
if not fileExists then
|
||||||
|
-- gzip check
|
||||||
|
fileExists = file.open(uri.file .. ".gz", "r")
|
||||||
file.close()
|
file.close()
|
||||||
if not fileExists then
|
|
||||||
|
if fileExists then
|
||||||
|
print("gzip variant exists, serving that one")
|
||||||
|
uri.file = uri.file .. ".gz"
|
||||||
|
uri.ext = uri.ext .. ".gz"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not fileExists then
|
||||||
uri.args = {code = 404, errorString = "Not Found"}
|
uri.args = {code = 404, errorString = "Not Found"}
|
||||||
fileServeFunction = dofile("httpserver-error.lc")
|
fileServeFunction = dofile("httpserver-error.lc")
|
||||||
elseif uri.isScript then
|
elseif uri.isScript then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user