Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(router) preserve_host always fetches the request's Host #2832

Merged
merged 1 commit into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions kong/core/router.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ local tonumber = tonumber
local ipairs = ipairs
local pairs = pairs
local type = type
local next = next
local band = bit.band
local bor = bit.bor
local ERR = ngx.ERR
Expand Down Expand Up @@ -588,17 +587,14 @@ function _M.new(apis)
end)


local grab_host = #wildcard_hosts > 0 or next(plain_indexes.hosts) ~= nil


local function find_api(req_method, req_uri, req_host, ngx)
if type(req_method) ~= "string" then
return error("arg #1 method must be a string")
end
if type(req_uri) ~= "string" then
return error("arg #2 uri must be a string")
end
if req_host and type(req_host) ~= "string" then
if type(req_host) ~= "string" then
return error("arg #3 host must be a string")
end

Expand Down Expand Up @@ -831,13 +827,7 @@ function _M.new(apis)
end
end

--print("grab host header: ", grab_host)

local req_host

if grab_host then
req_host = ngx.var.http_host
end
local req_host = ngx.var.http_host

local match_t = find_api(method, uri, req_host, ngx)
if not match_t then
Expand Down
Loading