Increase chunk size, improved traces for debugging purposes.
This commit is contained in:
parent
2ae0a573d9
commit
e571f19d81
BIN
http/delorean.jpg
Normal file
BIN
http/delorean.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
@ -4,7 +4,7 @@
|
||||
|
||||
local function getMimeType(ext)
|
||||
-- A few MIME types. Keep list short. If you need something that is missing, let's add it.
|
||||
local mt = {css = "text/css",gif = "image/gif",html = "text/html",ico = "image/x-icon",jpeg = "image/jpeg",jpg = "image/jpeg",js = "application/javascript",png = "image/png"}
|
||||
local mt = {css = "text/css", gif = "image/gif", html = "text/html", ico = "image/x-icon", jpeg = "image/jpeg", jpg = "image/jpeg", js = "application/javascript", josn="application/json", png = "image/png"}
|
||||
if mt[ext] then return mt[ext] else return "text/plain" end
|
||||
end
|
||||
|
||||
@ -13,16 +13,15 @@ local function sendHeader(connection, code, codeString, mimeType)
|
||||
end
|
||||
|
||||
return function (connection, args)
|
||||
print("Serving:", args.file)
|
||||
sendHeader(connection, 200, "OK", getMimeType(args.ext))
|
||||
file.open(args.file)
|
||||
-- Send file in little chunks
|
||||
while true do
|
||||
local chunk = file.read(512)
|
||||
local chunk = file.read(1024)
|
||||
if chunk == nil then break end
|
||||
coroutine.yield()
|
||||
connection:send(chunk)
|
||||
end
|
||||
print("Finished sending file.")
|
||||
print("Finished sending:", args.file)
|
||||
file.close()
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user