This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new f6cdc794e perf: don't cache all request headers on critical code path 
(#7287)
f6cdc794e is described below

commit f6cdc794e25e211ce1fb0a4d1382539f5a3d1ab5
Author: soulbird <[email protected]>
AuthorDate: Wed Jun 22 11:45:18 2022 +0800

    perf: don't cache all request headers on critical code path (#7287)
---
 apisix/init.lua | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/apisix/init.lua b/apisix/init.lua
index af0f22553..08899f4ab 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -56,7 +56,6 @@ local str_byte        = string.byte
 local str_sub         = string.sub
 local tonumber        = tonumber
 local pairs           = pairs
-local type            = type
 local control_api_router
 
 local is_http = false
@@ -228,13 +227,9 @@ end
 local function set_upstream_headers(api_ctx, picked_server)
     set_upstream_host(api_ctx, picked_server)
 
-    local hdr = core.request.header(api_ctx, "X-Forwarded-Proto")
-    if hdr then
-        if type(hdr) == "table" then
-            api_ctx.var.var_x_forwarded_proto = hdr[1]
-        else
-            api_ctx.var.var_x_forwarded_proto = hdr
-        end
+    local proto = api_ctx.var.http_x_forwarded_proto
+    if proto then
+        api_ctx.var.var_x_forwarded_proto = proto
     end
 end
 

Reply via email to