Merge pull request #33 from hazarkarabay/gzip-variant
Use gzipped file if exists
This commit is contained in:
commit
af57939e0d
@ -24,6 +24,19 @@ return function (port)
|
||||
else
|
||||
local fileExists = file.open(uri.file, "r")
|
||||
file.close()
|
||||
|
||||
if not fileExists then
|
||||
-- gzip check
|
||||
fileExists = file.open(uri.file .. ".gz", "r")
|
||||
file.close()
|
||||
|
||||
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"}
|
||||
fileServeFunction = dofile("httpserver-error.lc")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user