aboutsummaryrefslogtreecommitdiffstats
path: root/msb-core/openresty-ext/src/assembly/resources/openresty/lualib/resty/http_headers.lua
diff options
context:
space:
mode:
authorHuabingZhao <zhao.huabing@zte.com.cn>2017-07-25 15:18:33 +0800
committerHuabingZhao <zhao.huabing@zte.com.cn>2017-07-25 18:11:59 +0800
commit672f3d40be83d9e380fd7be4b674d5e8d5fa36de (patch)
tree43105e1d5e2ba8e8accea8648e57e1cf87db3f00 /msb-core/openresty-ext/src/assembly/resources/openresty/lualib/resty/http_headers.lua
parent41d3db15a8e1a0496f9c2a5e15db2998a32bb9bf (diff)
Divide the MSB source codes into two repos
Change-Id: Ie76d545b214a8ce5191f215350a623e1529983d9 Issue-id: MSB-5 Signed-off-by: HuabingZhao <zhao.huabing@zte.com.cn>
Diffstat (limited to 'msb-core/openresty-ext/src/assembly/resources/openresty/lualib/resty/http_headers.lua')
-rw-r--r--msb-core/openresty-ext/src/assembly/resources/openresty/lualib/resty/http_headers.lua62
1 files changed, 0 insertions, 62 deletions
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/lualib/resty/http_headers.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/lualib/resty/http_headers.lua
deleted file mode 100644
index 24b53b5..0000000
--- a/msb-core/openresty-ext/src/assembly/resources/openresty/lualib/resty/http_headers.lua
+++ /dev/null
@@ -1,62 +0,0 @@
-local rawget, rawset, setmetatable =
- rawget, rawset, setmetatable
-
-local str_gsub = string.gsub
-local str_lower = string.lower
-
-
-local _M = {
- _VERSION = '0.01',
-}
-
-
--- Returns an empty headers table with internalised case normalisation.
--- Supports the same cases as in ngx_lua:
---
--- headers.content_length
--- headers["content-length"]
--- headers["Content-Length"]
-function _M.new(self)
- local mt = {
- normalised = {},
- }
-
-
- mt.__index = function(t, k)
- local k_hyphened = str_gsub(k, "_", "-")
- local matched = rawget(t, k)
- if matched then
- return matched
- else
- local k_normalised = str_lower(k_hyphened)
- return rawget(t, mt.normalised[k_normalised])
- end
- end
-
-
- -- First check the normalised table. If there's no match (first time) add an entry for
- -- our current case in the normalised table. This is to preserve the human (prettier) case
- -- instead of outputting lowercased header names.
- --
- -- If there's a match, we're being updated, just with a different case for the key. We use
- -- the normalised table to give us the original key, and perorm a rawset().
- mt.__newindex = function(t, k, v)
- -- we support underscore syntax, so always hyphenate.
- local k_hyphened = str_gsub(k, "_", "-")
-
- -- lowercase hyphenated is "normalised"
- local k_normalised = str_lower(k_hyphened)
-
- if not mt.normalised[k_normalised] then
- mt.normalised[k_normalised] = k_hyphened
- rawset(t, k_hyphened, v)
- else
- rawset(t, mt.normalised[k_normalised], v)
- end
- end
-
- return setmetatable({}, mt)
-end
-
-
-return _M