Skip to content

Commit d389214

Browse files
committed
test: add tests to check that client pooling works before any requests, and after 2 requests
1 parent c3d4e1e commit d389214

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

t/07-keepalive.t

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,3 +523,67 @@ response not fully read
523523
--- no_error_log
524524
[error]
525525
[warn]
526+
527+
=== TEST 10 Pooling connection immediately after creation should work
528+
--- http_config eval: $::HttpConfig
529+
--- config
530+
location = /a {
531+
content_by_lua '
532+
local http = require "resty.http"
533+
local httpc = http.new()
534+
ngx.say(httpc:set_keepalive())
535+
';
536+
}
537+
--- request
538+
GET /a
539+
--- response_body
540+
1
541+
--- no_error_log
542+
[error]
543+
[warn]
544+
545+
=== TEST 11 Reusing client still checks pooling is ready
546+
--- http_config eval: $::HttpConfig
547+
--- config
548+
location = /a {
549+
content_by_lua '
550+
local http = require "resty.http"
551+
local httpc = http.new()
552+
httpc:connect({
553+
scheme = "http",
554+
host = "127.0.0.1",
555+
port = ngx.var.server_port,
556+
pool_only_after_response = true
557+
})
558+
559+
local res, err = httpc:request{
560+
path = "/b"
561+
}
562+
563+
local body = res:read_body()
564+
565+
ngx.say(res.headers["Connection"])
566+
ngx.say(httpc:set_keepalive())
567+
568+
res, err = httpc:request{
569+
path = "/b"
570+
}
571+
local ok
572+
ok, err = httpc:set_keepalive())
573+
ngx.say(err)
574+
';
575+
}
576+
location = /b {
577+
content_by_lua '
578+
ngx.say("OK")
579+
';
580+
}
581+
--- request
582+
GET /a
583+
--- response_body
584+
keep-alive
585+
1
586+
response not fully read
587+
--- no_error_log
588+
[error]
589+
[warn]

0 commit comments

Comments
 (0)