From ee75be92ed683d92bbe87ab876ed412d8583bf65 Mon Sep 17 00:00:00 2001 From: lijunlong Date: Tue, 28 May 2024 09:38:38 +0800 Subject: [PATCH] optimize: validate the connection header before transfering to lower. --- lib/resty/http.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/resty/http.lua b/lib/resty/http.lua index a85f85a..2646c34 100644 --- a/lib/resty/http.lua +++ b/lib/resty/http.lua @@ -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