Skip to content

Commit a77292e

Browse files
committed
Test: simple interface keepalive settings
1 parent 54b52db commit a77292e

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

t/07-keepalive.t

+67
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,70 @@ connection must be closed
244244
--- no_error_log
245245
[error]
246246
[warn]
247+
248+
=== TEST 6: Simple interface, override settings
249+
--- http_config eval: $::HttpConfig
250+
--- config
251+
location = /a {
252+
content_by_lua_block {
253+
local http = require "resty.http"
254+
local httpc = http.new()
255+
local res, err = httpc:request_uri(
256+
"http://127.0.0.1:"..ngx.var.server_port.."/b",
257+
{
258+
keepalive = false
259+
}
260+
)
261+
262+
ngx.say(res.headers["Connection"])
263+
264+
httpc:connect("127.0.0.1", ngx.var.server_port)
265+
ngx.say(httpc:get_reused_times())
266+
httpc:close()
267+
268+
local res, err = httpc:request_uri(
269+
"http://127.0.0.1:"..ngx.var.server_port.."/b",
270+
{
271+
keepalive_timeout = 10
272+
}
273+
)
274+
275+
ngx.say(res.headers["Connection"])
276+
277+
httpc:connect("127.0.0.1", ngx.var.server_port)
278+
ngx.say(httpc:get_reused_times())
279+
httpc:close()
280+
281+
local res, err = httpc:request_uri(
282+
"http://127.0.0.1:"..ngx.var.server_port.."/b",
283+
{
284+
keepalive_timeout = 1
285+
}
286+
)
287+
288+
ngx.say(res.headers["Connection"])
289+
290+
ngx.sleep(1.1)
291+
292+
httpc:connect("127.0.0.1", ngx.var.server_port)
293+
ngx.say(httpc:get_reused_times())
294+
httpc:close()
295+
}
296+
}
297+
location = /b {
298+
content_by_lua_block {
299+
ngx.say("OK")
300+
}
301+
}
302+
--- request
303+
GET /a
304+
--- response_body
305+
keep-alive
306+
0
307+
keep-alive
308+
1
309+
keep-alive
310+
0
311+
--- no_error_log
312+
[error]
313+
[warn]

0 commit comments

Comments
 (0)