Mercurial > hg > nginx-tests
comparison h2_ssl.t @ 1901:f9bb84e4c8e2
Tests: added HTTP/2 test with invalid h2c over ssl socket.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 31 May 2023 13:29:34 +0400 |
parents | 58951cf933e1 |
children | 2a0a6035a1af |
comparison
equal
deleted
inserted
replaced
1900:236d038dc04a | 1901:f9bb84e4c8e2 |
---|---|
80 open OLDERR, ">&", \*STDERR; close STDERR; | 80 open OLDERR, ">&", \*STDERR; close STDERR; |
81 $t->run(); | 81 $t->run(); |
82 open STDERR, ">&", \*OLDERR; | 82 open STDERR, ">&", \*OLDERR; |
83 | 83 |
84 plan(skip_all => 'no ALPN negotiation') unless defined getconn(); | 84 plan(skip_all => 'no ALPN negotiation') unless defined getconn(); |
85 $t->plan(3); | 85 $t->plan(4); |
86 | 86 |
87 ############################################################################### | 87 ############################################################################### |
88 | 88 |
89 SKIP: { | 89 SKIP: { |
90 skip 'LibreSSL too old', 1 | 90 skip 'LibreSSL too old', 1 |
109 my $s = getconn(['http/1.1', 'h2']); | 109 my $s = getconn(['http/1.1', 'h2']); |
110 my $sid = $s->new_stream(); | 110 my $sid = $s->new_stream(); |
111 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | 111 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
112 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 112 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
113 is($frame->{headers}->{':status'}, 200, 'alpn to HTTP/2'); | 113 is($frame->{headers}->{':status'}, 200, 'alpn to HTTP/2'); |
114 | |
115 # h2c preface on ssl-enabled socket is rejected as invalid HTTP/1.x request, | |
116 # ensure that HTTP/2 auto-detection doesn't kick in | |
117 | |
118 like(http("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"), qr/Bad Request/, | |
119 'no h2c on ssl socket'); | |
114 | 120 |
115 # client cancels last stream after HEADERS has been created, | 121 # client cancels last stream after HEADERS has been created, |
116 # while some unsent data was left in the SSL buffer | 122 # while some unsent data was left in the SSL buffer |
117 # HEADERS frame may stuck in SSL buffer and won't be sent producing alert | 123 # HEADERS frame may stuck in SSL buffer and won't be sent producing alert |
118 | 124 |