Skip to content

Commit

Permalink
perf(*): perhaps a slightly faster upstream VIA header
Browse files Browse the repository at this point in the history
Signed-off-by: Aapo Talvensaari <aapo.talvensaari@gmail.com>
  • Loading branch information
bungle committed Sep 5, 2024
1 parent 7b4f198 commit 4ea8834
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions kong/runloop/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ local STREAM_TLS_TERMINATE_SOCK
local STREAM_TLS_PASSTHROUGH_SOCK


local VIA_HEADER = {
[0.9] = "0.9 " .. SERVER_HEADER,
[1.0] = "1.0 " .. SERVER_HEADER,
[1.1] = "1.1 " .. SERVER_HEADER,
[2.0] = "2.0 " .. SERVER_HEADER,
[3.0] = "3.0 " .. SERVER_HEADER,
}


local get_header
local set_authority
local set_service_ssl = upstream_ssl.set_service_ssl
Expand Down Expand Up @@ -1290,13 +1299,9 @@ return {
var.upstream_x_forwarded_path = forwarded_path
var.upstream_x_forwarded_prefix = forwarded_prefix

do
local req_via = get_header(constants.HEADERS.VIA, ctx)
local kong_inbound_via = protocol_version and protocol_version .. " " .. SERVER_HEADER
or SERVER_HEADER
var.upstream_via = req_via and req_via .. ", " .. kong_inbound_via
or kong_inbound_via
end
local req_via = get_header("via", ctx)
local kong_via = VIA_HEADER[protocol_version or ""] or SERVER_HEADER
var.upstream_via = req_via and (req_via .. ", " .. kong_via) or kong_via

-- At this point, the router and `balancer_setup_stage1` have been
-- executed; detect requests that need to be redirected from `proxy_pass`
Expand Down

0 comments on commit 4ea8834

Please sign in to comment.