comparison http_keepalive_shutdown.t @ 1753:0c50a00e6733

Tests: added http keepalive test for Connection header on shutdown.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 11 Jan 2022 17:39:28 +0300
parents
children 2a0a6035a1af
comparison
equal deleted inserted replaced
1752:ba6e24e38f03 1753:0c50a00e6733
1 #!/usr/bin/perl
2
3 # (C) Sergey Kandaurov
4 # (C) Nginx, Inc.
5
6 # Tests for http keepalive connections on worker shutdown.
7
8 ###############################################################################
9
10 use warnings;
11 use strict;
12
13 use Test::More;
14
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
16
17 use lib 'lib';
18 use Test::Nginx qw/ :DEFAULT http_end /;
19
20 ###############################################################################
21
22 select STDERR; $| = 1;
23 select STDOUT; $| = 1;
24
25 my $t = Test::Nginx->new()->has(qw/http limit_req/)->plan(1);
26
27 $t->write_file_expand('nginx.conf', <<'EOF');
28
29 %%TEST_GLOBALS%%
30
31 daemon off;
32
33 events {
34 }
35
36 http {
37 %%TEST_GLOBALS_HTTP%%
38
39 limit_req_zone $binary_remote_addr zone=one:1m rate=1r/s;
40
41 server {
42 listen 127.0.0.1:8080;
43 server_name localhost;
44
45 location / {
46 limit_req zone=one burst=5;
47 }
48 }
49 }
50
51 EOF
52
53 $t->write_file('test.html', 'XtestX');
54 $t->run();
55
56 ###############################################################################
57
58 local $TODO = 'not yet' unless $t->has_version('1.21.6');
59
60 # signaling on graceful shutdown to client that keepalive connection is closing
61
62 my $s = http(<<EOF, start => 1);
63 HEAD /test.html HTTP/1.1
64 Host: localhost
65
66 HEAD /test.html HTTP/1.1
67 Host: localhost
68
69 EOF
70
71 select undef, undef, undef, 0.1;
72
73 $t->stop();
74
75 like(http_end($s), qr/Connection: close/, 'connection close on exit');
76
77 ###############################################################################