Skip to content

Commit

Permalink
Proper case for set of predefined parts
Browse files Browse the repository at this point in the history
  • Loading branch information
johnd0e committed Jan 4, 2025
1 parent d4bc6b5 commit 4160ef1
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/headers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,37 @@ local socket = require("socket")
socket.headers = {}
local _M = socket.headers

local parts = {
ch="CH",
dns="DNS",
ect="ECT",
etag="ETag",
gpc="GPC",
id="ID",
md5="MD5",
mime="MIME",
mta="MTA",
nel="NEL",
rtt="RTT",
smtp="SMTP",
sourcemap="SourceMap",
te="TE",
ua="UA",
websocket="WebSocket",
wow64="WoW64",
www="WWW",
xss="XSS",
}

_M.canonic = setmetatable({},{
__index=function (t,k)
t[k] = string.gsub(k, "%f[%w]%l", string.upper)
t[k] = string.gsub(k, "%f[%w]%l", function (part)
return parts[part] or string.upper(part)
end)
return t[k]
end;
})

_M.parts = parts

return _M

0 comments on commit 4160ef1

Please sign in to comment.