annotate h2_ssl.t @ 1961:fe6f22da53ec default tip

Tests: tests for usage of discarded body. The client_max_body_size limit should be ignored when the request body is already discarded. In HTTP/1.x, this is done by checking the r->discard_body flag when the body is being discarded, and because r->headers_in.content_length_n is 0 when it's already discarded. This, however, does not happen with HTTP/2 and HTTP/3, and therefore "error_page 413" does not work without relaxing the limit. Further, with proxy_pass, r->headers_in.content_length_n is used to determine length of the request body, and therefore is not correct if discarding of the request body isn't yet complete. While discarding the request body, r->headers_in.content_length_n contains the rest of the body to discard (or, in case of chunked request body, the rest of the current chunk to discard). Similarly, the $content_length variable uses r->headers_in.content_length if available, and also incorrect. The $content_length variable is used when proxying with fastcgi_pass, grpc_pass, and uwsgi_pass (scgi_pass uses the value calculated based on the actual request body buffers, and therefore works correctly).
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 27 Apr 2024 18:55:50 +0300
parents 2a0a6035a1af
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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();
1901
f9bb84e4c8e2 Tests: added HTTP/2 test with invalid h2c over ssl socket.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1860
diff changeset
85 $t->plan(4);
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 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
98
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
1740
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
101 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
102 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
103
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
104 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
105 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
106 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
107 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
108 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
109
1901
f9bb84e4c8e2 Tests: added HTTP/2 test with invalid h2c over ssl socket.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1860
diff changeset
110 # h2c preface on ssl-enabled socket is rejected as invalid HTTP/1.x request,
f9bb84e4c8e2 Tests: added HTTP/2 test with invalid h2c over ssl socket.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1860
diff changeset
111 # ensure that HTTP/2 auto-detection doesn't kick in
f9bb84e4c8e2 Tests: added HTTP/2 test with invalid h2c over ssl socket.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1860
diff changeset
112
f9bb84e4c8e2 Tests: added HTTP/2 test with invalid h2c over ssl socket.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1860
diff changeset
113 like(http("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"), qr/Bad Request/,
f9bb84e4c8e2 Tests: added HTTP/2 test with invalid h2c over ssl socket.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1860
diff changeset
114 'no h2c on ssl socket');
f9bb84e4c8e2 Tests: added HTTP/2 test with invalid h2c over ssl socket.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1860
diff changeset
115
1740
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
116 # 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
117 # 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
118 # 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
119
1788
78fe648d54a7 Tests: avoid send timeout in h2_ssl.t test with canceled streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1744
diff changeset
120 $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
121 $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
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 ###############################################################################