You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org> on 2023/03/24 02:49:09 UTC

[GitHub] [apisix] monkeyDluffy6017 commented on a diff in pull request #9150: fix: host_hdr should not be false

monkeyDluffy6017 commented on code in PR #9150:
URL: https://github.com/apache/apisix/pull/9150#discussion_r1147063301


##########
apisix/upstream.lua:
##########
@@ -134,10 +134,13 @@ local function create_checker(upstream)
 
     local host = upstream.checks and upstream.checks.active and upstream.checks.active.host
     local port = upstream.checks and upstream.checks.active and upstream.checks.active.port
-    local up_hdr = upstream.pass_host == "rewrite" and upstream.upstream_host
-    local use_node_hdr = upstream.pass_host == "node"
     for _, node in ipairs(upstream.nodes) do
-        local host_hdr = up_hdr or (use_node_hdr and node.domain)
+        local host_hdr
+        if upstream.pass_host == "rewrite" and upstream.upstream_host then
+            host_hdr = upstream.upstream_host
+        elseif upstream.pass_host == "node" and node.domain then
+            host_hdr = node.domain
+        end

Review Comment:
   The `up_hdr` won't affect the result of `host_hdr`. would this be better?
   ```
       local use_node_hdr = upstream.pass_host == "node" or nil     <== here
       for _, node in ipairs(upstream.nodes) do
           local host_hdr = up_hdr or (use_node_hdr and node.domain)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org