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

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


The following commit(s) were added to refs/heads/release/2.13 by this push:
     new 597955993 backport: commits to release/2.13 (#7319)
597955993 is described below

commit 5979559934c80ff682ea6025abccaee7c55d0fb1
Author: soulbird <[email protected]>
AuthorDate: Sun Jun 26 20:02:26 2022 +0800

    backport: commits to release/2.13 (#7319)
    
    * fix: duplicate X-Forwarded-Proto will be sent as string (#7229)
    
    Co-authored-by: soulbird <[email protected]>
    
    * perf: don't cache all request headers on critical code path (#7287)
    
    Co-authored-by: soulbird <[email protected]>
---
 apisix/init.lua           |  6 +++---
 t/plugin/proxy-rewrite2.t | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/apisix/init.lua b/apisix/init.lua
index a2eb17d1c..3586fea28 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -275,9 +275,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
-        api_ctx.var.var_x_forwarded_proto = hdr
+    local proto = api_ctx.var.http_x_forwarded_proto
+    if proto then
+        api_ctx.var.var_x_forwarded_proto = proto
     end
 end
 
diff --git a/t/plugin/proxy-rewrite2.t b/t/plugin/proxy-rewrite2.t
index 4fbfe55ba..fcd4011ba 100644
--- a/t/plugin/proxy-rewrite2.t
+++ b/t/plugin/proxy-rewrite2.t
@@ -208,3 +208,27 @@ X-Forwarded-Proto: grpc
 X-Forwarded-Proto: https-rewrite
 --- error_log
 localhost
+
+
+
+=== TEST 7: pass duplicate  X-Forwarded-Proto
+--- apisix_yaml
+routes:
+  -
+    id: 1
+    uri: /echo
+    upstream_id: 1
+upstreams:
+  -
+    id: 1
+    nodes:
+        "127.0.0.1:1980": 1
+    type: roundrobin
+#END
+--- request
+GET /echo
+--- more_headers
+X-Forwarded-Proto: http
+X-Forwarded-Proto: grpc
+--- response_headers
+X-Forwarded-Proto: http

Reply via email to