Skip to content

Commit

Permalink
optimize: validate the connection header before transfering to lower.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuizhuhaomeng committed May 28, 2024
1 parent 1833103 commit ee75be9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/resty/http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,9 @@ function _M.read_response(self, params)
end

-- keepalive is true by default. Determine if this is correct or not.
local ok, connection = pcall(str_lower, res_headers["Connection"])
if ok then
local connection = res_headers["Connection"]
if connection ~= nil then
connection = str_lower(connection)
if (version == 1.1 and str_find(connection, "close", 1, true)) or
(version == 1.0 and not str_find(connection, "keep-alive", 1, true)) then
self.keepalive = false
Expand Down

0 comments on commit ee75be9

Please sign in to comment.