Skip to content

Commit 0b65210

Browse files
committed
bugfix: the keepalive feature is hindered
1 parent fa6fb05 commit 0b65210

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/resty/requests/adapter.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ end
6161

6262

6363
local function parse_status_line(status_line)
64-
local m, err = ngx_match(status_line, "HTTP/(.+?)\\s.*?(\\d+).*", "jo")
64+
local m, err = ngx_match(status_line, "(HTTP/.+?)\\s.*?(\\d+).*", "jo")
6565
if not m then
6666
return nil, err
6767
end

lib/resty/requests/response.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,13 @@ local function new(opts)
221221
end
222222
end
223223

224+
local http_ver = r._http_ver
224225
local connection = r.headers["connection"]
225-
if connection == "keep-alive" or r._http_ver == HTTP20 then
226+
227+
if connection == "keep-alive"
228+
or (not connection and http_ver == HTTP11) -- HTTP/1.1 default behavior
229+
or http_ver == HTTP20
230+
then
226231
r._keepalive = true
227232
end
228233

0 commit comments

Comments
 (0)