mirror of
				https://github.com/lunarmodules/luasocket.git
				synced 2025-10-31 10:25:55 +01:00 
			
		
		
		
	Proper case for set of predefined parts
Ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
This commit is contained in:
		| @@ -7,11 +7,37 @@ local socket = require("socket") | |||||||
| socket.headers = {} | socket.headers = {} | ||||||
| local _M = 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({},{ | _M.canonic = setmetatable({},{ | ||||||
|   __index=function (t,k) |   __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] |     return t[k] | ||||||
|   end; |   end; | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | _M.parts = parts | ||||||
|  |  | ||||||
| return _M | return _M | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user