Skip to content

Commit de1d62b

Browse files
committed
fix: keepalive_ready mark only after connection
1 parent b636915 commit de1d62b

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

lib/resty/http.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function _M.new(_)
135135
return nil, err
136136
end
137137
return setmetatable({
138-
sock = sock, keepalive_supported = true, keepalive_ready = true, pool_only_after_response = false
138+
sock = sock, keepalive_supported = true, keepalive_ready = false, pool_only_after_response = false
139139
}, mt)
140140
end
141141

lib/resty/http_connect.lua

+2
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ local function connect(self, options)
224224

225225
self.host = request_host
226226
self.port = request_port
227+
-- Immediately after connection - keepalive should be possible
228+
self.keepalive_ready = true
227229
self.keepalive_supported = true
228230
self.ssl = ssl
229231
-- set only for http, https has already been handled

t/07-keepalive.t

+7-1
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,19 @@ response not fully read
524524
[error]
525525
[warn]
526526

527-
=== TEST 10 Pooling connection immediately after creation should work
527+
=== TEST 10 Pooling connection immediately after connecting should work
528528
--- http_config eval: $::HttpConfig
529529
--- config
530530
location = /a {
531531
content_by_lua '
532532
local http = require "resty.http"
533533
local httpc = http.new()
534+
httpc:connect({
535+
scheme = "http",
536+
host = "127.0.0.1",
537+
port = ngx.var.server_port,
538+
pool_only_after_response = true
539+
})
534540
ngx.say(httpc:set_keepalive())
535541
';
536542
}

0 commit comments

Comments
 (0)