Skip to content
Merged
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
13 changes: 7 additions & 6 deletions lib/resty/http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -798,15 +798,16 @@ 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
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
local connection = res_headers["Connection"]
if type(connection) ~= "string" then
-- no connection header (or duplicated as a table)
if version == 1.0 then
self.keepalive = false
end
else
-- no connection header
if version == 1.0 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
end
end
Expand Down
Loading