From 682f8ccfe9fa0239ef83735c3398c74a7812890a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=B3=BD=E8=BD=A9?= Date: Sat, 19 Feb 2022 23:31:47 +0800 Subject: [PATCH] fix: should not limit the header number (#6379) --- apisix/core/request.lua | 2 +- apisix/plugins/request-validation.lua | 4 ++-- t/core/request.t | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/apisix/core/request.lua b/apisix/core/request.lua index c15ac62e2b57..1bd8aafee0f0 100644 --- a/apisix/core/request.lua +++ b/apisix/core/request.lua @@ -43,7 +43,7 @@ local function _headers(ctx) end local headers = ctx.headers if not headers then - headers = get_headers() + headers = get_headers(0) ctx.headers = headers end diff --git a/apisix/plugins/request-validation.lua b/apisix/plugins/request-validation.lua index e64a9cec372d..0b3b0f3e18f3 100644 --- a/apisix/plugins/request-validation.lua +++ b/apisix/plugins/request-validation.lua @@ -66,8 +66,8 @@ function _M.check_schema(conf) end -function _M.rewrite(conf) - local headers = ngx.req.get_headers() +function _M.rewrite(conf, ctx) + local headers = core.request.headers(ctx) if conf.header_schema then local ok, err = core.schema.check(conf.header_schema, headers) diff --git a/t/core/request.t b/t/core/request.t index 7d688c9886eb..0f0acb414a3b 100644 --- a/t/core/request.t +++ b/t/core/request.t @@ -422,3 +422,24 @@ the post form is too large: request body in temp file not supported POST /t --- response_body POST + + + +=== TEST 14: get header +--- config + location /t { + content_by_lua_block { + local core = require("apisix.core") + ngx.say(core.request.header(ngx.ctx, "X-101")) + } + } +--- more_headers eval +my $i = 1; +my $s; +while ($i <= 101) { + $s .= "X-$i:$i\n"; + $i++; +} +$s +--- response_body +101