AlinsRan commented on code in PR #12086: URL: https://github.com/apache/apisix/pull/12086#discussion_r2022184552
########## apisix/lua_proxy.lua: ########## @@ -0,0 +1,165 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +local _M = {} +local core = require("apisix.core") +local http = require("resty.http") + +local HTTP_GATEWAY_TIMEOUT = ngx.HTTP_GATEWAY_TIMEOUT +local HTTP_INTERNAL_SERVER_ERROR = ngx.HTTP_INTERNAL_SERVER_ERROR + + +local function handle_error(err) + if core.string.find(err, "timeout") then + return HTTP_GATEWAY_TIMEOUT + end + return HTTP_INTERNAL_SERVER_ERROR +end + + +local function build_request_opts(conf, ctx) + -- Get upstream server + local server = ctx.picked_server + if not server then + return nil, "no picked server" + end + + local headers = core.request.headers(ctx) + -- When content-length is cleared, the HTTP server will automatically calculate and + -- set the correct content length when sending the response. This ensures that the + -- content length of the response matches the actual data sent, thereby avoiding mismatches. + headers["content-length"] = nil + + -- Build request options + local opts = { + scheme = server.scheme or ctx.upstream_scheme or "http", + host = server.domain or server.host, + port = server.port, + path = ctx.var.uri, + query = ctx.var.args, + method = core.request.get_method(), + headers = headers, + ssl_verify = conf.ssl_verify, + keepalive = conf.keepalive, + keepalive_timeout = conf.timeout, Review Comment: This `timeout` is unclear. The meanings of connection timeout and idle connection timeout are different. I suggest using `keepalive_timeout` -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
