Mercurial > hg > nginx-tests
annotate h2_ssl.t @ 1743:2318ed01ce53
Tests: skip ALPN rejection tests with too old LibreSSL.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 21 Oct 2021 20:18:01 +0300 |
parents | 3408029c09f5 |
children | 38bd7e75fe69 |
rev | line source |
---|---|
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for HTTP/2 protocol with ssl. |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP2; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2/) |
1033
45c80276d691
Tests: unbreak for nginx built with OpenSSL without NPN/ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
997
diff
changeset
|
27 ->has_daemon('openssl'); |
45c80276d691
Tests: unbreak for nginx built with OpenSSL without NPN/ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
997
diff
changeset
|
28 |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 $t->write_file_expand('nginx.conf', <<'EOF'); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 %%TEST_GLOBALS%% |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 daemon off; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 events { |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 } |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 http { |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server { |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 listen 127.0.0.1:8080 http2 ssl; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server_name localhost; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 ssl_certificate_key localhost.key; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 ssl_certificate localhost.crt; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
1654
341506267e16
Tests: HTTP/2 tests speedup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1488
diff
changeset
|
48 lingering_close off; |
341506267e16
Tests: HTTP/2 tests speedup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1488
diff
changeset
|
49 |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 location / { } |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 } |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 } |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 EOF |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
56 eval { require IO::Socket::SSL; die if $IO::Socket::SSL::VERSION < 1.56; }; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
57 plan(skip_all => 'IO::Socket::SSL version >= 1.56 required') if $@; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
58 |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
59 eval { IO::Socket::SSL->can_alpn() or die; }; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
60 plan(skip_all => 'IO::Socket::SSL with OpenSSL ALPN support required') if $@; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
61 |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
62 eval { exists &Net::SSLeay::P_alpn_selected or die; }; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
63 plan(skip_all => 'Net::SSLeay with OpenSSL ALPN support required') if $@; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
64 |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 $t->write_file('openssl.conf', <<EOF); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 [ req ] |
1488
dbce8fb5f5f8
Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1220
diff
changeset
|
67 default_bits = 2048 |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 encrypt_key = no |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 distinguished_name = req_distinguished_name |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 [ req_distinguished_name ] |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 EOF |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 my $d = $t->testdir(); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 foreach my $name ('localhost') { |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 system('openssl req -x509 -new ' |
1220
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
77 . "-config $d/openssl.conf -subj /CN=$name/ " |
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
78 . "-out $d/$name.crt -keyout $d/$name.key " |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 . ">>$d/openssl.out 2>&1") == 0 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 or die "Can't create certificate for $name: $!\n"; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 } |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
83 $t->write_file('index.html', ''); |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 $t->write_file('tbig.html', |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 join('', map { sprintf "XX%06dXX", $_ } (1 .. 500000))); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 open OLDERR, ">&", \*STDERR; close STDERR; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 $t->run(); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 open STDERR, ">&", \*OLDERR; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
91 plan(skip_all => 'no ALPN negotiation') unless defined getconn(); |
1741
3408029c09f5
Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1740
diff
changeset
|
92 $t->plan(3); |
1033
45c80276d691
Tests: unbreak for nginx built with OpenSSL without NPN/ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
997
diff
changeset
|
93 |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 ############################################################################### |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
1743
2318ed01ce53
Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1741
diff
changeset
|
96 SKIP: { |
2318ed01ce53
Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1741
diff
changeset
|
97 $t->{_configure_args} =~ /LibreSSL ([\d\.]+)/; |
2318ed01ce53
Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1741
diff
changeset
|
98 skip 'LibreSSL too old', 1 if defined $1 and $1 lt '3.4.0'; |
2318ed01ce53
Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1741
diff
changeset
|
99 |
1741
3408029c09f5
Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1740
diff
changeset
|
100 TODO: { |
3408029c09f5
Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1740
diff
changeset
|
101 local $TODO = 'not yet' unless $t->has_version('1.21.4'); |
3408029c09f5
Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1740
diff
changeset
|
102 |
3408029c09f5
Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1740
diff
changeset
|
103 ok(!get_ssl_socket(['unknown']), 'alpn rejected'); |
3408029c09f5
Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1740
diff
changeset
|
104 |
3408029c09f5
Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1740
diff
changeset
|
105 } |
3408029c09f5
Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1740
diff
changeset
|
106 |
1743
2318ed01ce53
Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1741
diff
changeset
|
107 } |
2318ed01ce53
Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1741
diff
changeset
|
108 |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
109 like(http_get('/', socket => get_ssl_socket(['http/1.1'])), |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
110 qr/200 OK/, 'alpn to HTTP/1.1 fallback'); |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
111 |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
112 my $s = getconn(['http/1.1', 'h2']); |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
113 my $sid = $s->new_stream(); |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
114 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
115 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
116 is($frame->{headers}->{':status'}, 200, 'alpn to HTTP/2'); |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
117 |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
118 # client cancels last stream after HEADERS has been created, |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 # while some unsent data was left in the SSL buffer |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 # HEADERS frame may stuck in SSL buffer and won't be sent producing alert |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
122 $sid = $s->new_stream({ path => '/tbig.html' }); |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 select undef, undef, undef, 0.2; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 $s->h2_rst($sid, 8); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 $sid = $s->new_stream({ path => '/tbig.html' }); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 select undef, undef, undef, 0.2; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 $s->h2_rst($sid, 8); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 $t->stop(); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 ############################################################################### |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 sub getconn { |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
137 my ($alpn) = @_; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
138 $alpn = ['h2'] if !defined $alpn; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
139 |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
140 my $sock = get_ssl_socket($alpn); |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
141 my $s = Test::Nginx::HTTP2->new(undef, socket => $sock) |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
142 if $sock->alpn_selected(); |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
143 } |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
144 |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
145 sub get_ssl_socket { |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
146 my ($alpn) = @_; |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 my $s; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 eval { |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
150 local $SIG{ALRM} = sub { die "timeout\n" }; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
151 local $SIG{PIPE} = sub { die "sigpipe\n" }; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
152 alarm(8); |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
153 $s = IO::Socket::SSL->new( |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
154 Proto => 'tcp', |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
155 PeerAddr => '127.0.0.1', |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
156 PeerPort => port(8080), |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
157 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(), |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
158 SSL_alpn_protocols => $alpn, |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
159 SSL_error_trap => sub { die $_[1] } |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
160 ); |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
161 alarm(0); |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 }; |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
163 alarm(0); |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
165 if ($@) { |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
166 log_in("died: $@"); |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
167 return undef; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
168 } |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 return $s; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 } |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 ############################################################################### |