mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-20 15:59:48 +02:00
Almost ready for beta3
This commit is contained in:
11
src/mime.lua
11
src/mime.lua
@ -8,9 +8,10 @@
|
||||
-----------------------------------------------------------------------------
|
||||
-- Declare module and import dependencies
|
||||
-----------------------------------------------------------------------------
|
||||
module("mime")
|
||||
local mime = require("lmime")
|
||||
local base = require("base")
|
||||
local ltn12 = require("ltn12")
|
||||
local mime = require("lmime")
|
||||
module("mime")
|
||||
|
||||
-- encode, decode and wrap algorithm tables
|
||||
mime.encodet = {}
|
||||
@ -20,11 +21,11 @@ mime.wrapt = {}
|
||||
-- creates a function that chooses a filter by name from a given table
|
||||
local function choose(table)
|
||||
return function(name, opt1, opt2)
|
||||
if type(name) ~= "string" then
|
||||
if base.type(name) ~= "string" then
|
||||
name, opt1, opt2 = "default", name, opt1
|
||||
end
|
||||
local f = table[name or "nil"]
|
||||
if not f then error("unknown key (" .. tostring(name) .. ")", 3)
|
||||
if not f then error("unknown key (" .. base.tostring(name) .. ")", 3)
|
||||
else return f(opt1, opt2) end
|
||||
end
|
||||
end
|
||||
@ -74,3 +75,5 @@ end
|
||||
function mime.stuff()
|
||||
return ltn12.filter.cycle(dot, 2)
|
||||
end
|
||||
|
||||
base.setmetatable(mime, nil)
|
||||
|
Reference in New Issue
Block a user