Mercurial > hg > nginx-tests
annotate h2_ssl.t @ 1888:cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
STREAM and RESET_STREAM frames could be batched, which prevents the stream
from being processed and changes the status code. The fix is to wait for
the stream acknowledgment. Here we just look at the largest acknowledged,
this should be enough for simple cases.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 04 Apr 2023 00:33:54 +0400 |
parents | 58951cf933e1 |
children | f9bb84e4c8e2 |
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 |
1788
78fe648d54a7
Tests: avoid send timeout in h2_ssl.t test with canceled streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1744
diff
changeset
|
15 use Socket qw/ SOL_SOCKET SO_RCVBUF /; |
78fe648d54a7
Tests: avoid send timeout in h2_ssl.t test with canceled streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1744
diff
changeset
|
16 |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 use Test::Nginx::HTTP2; |
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 ############################################################################### |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDERR; $| = 1; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 select STDOUT; $| = 1; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
1858
cdcd75657e52
Tests: added has_feature() tests for IO::Socket::SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1788
diff
changeset
|
28 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 socket_ssl_alpn/) |
1033
45c80276d691
Tests: unbreak for nginx built with OpenSSL without NPN/ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
997
diff
changeset
|
29 ->has_daemon('openssl'); |
45c80276d691
Tests: unbreak for nginx built with OpenSSL without NPN/ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
997
diff
changeset
|
30 |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 $t->write_file_expand('nginx.conf', <<'EOF'); |
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 %%TEST_GLOBALS%% |
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 daemon off; |
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 events { |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 } |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 http { |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 %%TEST_GLOBALS_HTTP%% |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server { |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 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
|
45 server_name localhost; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 ssl_certificate_key localhost.key; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 ssl_certificate localhost.crt; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 |
1654
341506267e16
Tests: HTTP/2 tests speedup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1488
diff
changeset
|
50 lingering_close off; |
341506267e16
Tests: HTTP/2 tests speedup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1488
diff
changeset
|
51 |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 location / { } |
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 } |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 EOF |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 $t->write_file('openssl.conf', <<EOF); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 [ req ] |
1488
dbce8fb5f5f8
Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1220
diff
changeset
|
60 default_bits = 2048 |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 encrypt_key = no |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 distinguished_name = req_distinguished_name |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 [ req_distinguished_name ] |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 EOF |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 my $d = $t->testdir(); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 foreach my $name ('localhost') { |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 system('openssl req -x509 -new ' |
1220
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
70 . "-config $d/openssl.conf -subj /CN=$name/ " |
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
71 . "-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
|
72 . ">>$d/openssl.out 2>&1") == 0 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 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
|
74 } |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
76 $t->write_file('index.html', ''); |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 $t->write_file('tbig.html', |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 join('', map { sprintf "XX%06dXX", $_ } (1 .. 500000))); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 open OLDERR, ">&", \*STDERR; close STDERR; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 $t->run(); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 open STDERR, ">&", \*OLDERR; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
84 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
|
85 $t->plan(3); |
1033
45c80276d691
Tests: unbreak for nginx built with OpenSSL without NPN/ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
997
diff
changeset
|
86 |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 ############################################################################### |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 |
1743
2318ed01ce53
Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1741
diff
changeset
|
89 SKIP: { |
1860
58951cf933e1
Tests: added has_feature() test for SSL libraries.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1858
diff
changeset
|
90 skip 'LibreSSL too old', 1 |
58951cf933e1
Tests: added has_feature() test for SSL libraries.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1858
diff
changeset
|
91 if $t->has_module('LibreSSL') |
58951cf933e1
Tests: added has_feature() test for SSL libraries.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1858
diff
changeset
|
92 and not $t->has_feature('libressl:3.4.0'); |
58951cf933e1
Tests: added has_feature() test for SSL libraries.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1858
diff
changeset
|
93 skip 'OpenSSL too old', 1 |
58951cf933e1
Tests: added has_feature() test for SSL libraries.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1858
diff
changeset
|
94 if $t->has_module('OpenSSL') |
58951cf933e1
Tests: added has_feature() test for SSL libraries.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1858
diff
changeset
|
95 and not $t->has_feature('openssl:1.1.0'); |
1743
2318ed01ce53
Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1741
diff
changeset
|
96 |
1741
3408029c09f5
Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1740
diff
changeset
|
97 TODO: { |
3408029c09f5
Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1740
diff
changeset
|
98 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
|
99 |
3408029c09f5
Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1740
diff
changeset
|
100 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
|
101 |
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 |
1743
2318ed01ce53
Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1741
diff
changeset
|
104 } |
2318ed01ce53
Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1741
diff
changeset
|
105 |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
106 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
|
107 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
|
108 |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
109 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
|
110 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
|
111 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
|
112 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
|
113 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
|
114 |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
115 # 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
|
116 # 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
|
117 # 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
|
118 |
1788
78fe648d54a7
Tests: avoid send timeout in h2_ssl.t test with canceled streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1744
diff
changeset
|
119 $s = getconn(['http/1.1', 'h2']); |
78fe648d54a7
Tests: avoid send timeout in h2_ssl.t test with canceled streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1744
diff
changeset
|
120 $s->{socket}->setsockopt(SOL_SOCKET, SO_RCVBUF, 1024*1024) or die $!; |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
121 $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
|
122 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 select undef, undef, undef, 0.2; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 $s->h2_rst($sid, 8); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 $sid = $s->new_stream({ path => '/tbig.html' }); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 select undef, undef, undef, 0.2; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 $s->h2_rst($sid, 8); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 $t->stop(); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 |
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 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
|
136 my ($alpn) = @_; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
137 $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
|
138 |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
139 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
|
140 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
|
141 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
|
142 } |
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 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
|
145 my ($alpn) = @_; |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 my $s; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 eval { |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
149 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
|
150 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
|
151 alarm(8); |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
152 $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
|
153 Proto => 'tcp', |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
154 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
|
155 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
|
156 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
|
157 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
|
158 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
|
159 ); |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
160 alarm(0); |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 }; |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
162 alarm(0); |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 |
1740
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
164 if ($@) { |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
165 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
|
166 return undef; |
f7e667a4898d
Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1654
diff
changeset
|
167 } |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 return $s; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 } |
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 ############################################################################### |