# HG changeset patch # User Sergey Kandaurov # Date 1443215002 -10800 # Node ID e3fd2c8d257ed0af1df8bbfecd1a3e5f577d8af8 # Parent 9ee52e137f3d77e3c57862a51b05e77aa87e7df6 Tests: added HTTP/2 tests for some http core module variables. diff --git a/h2.t b/h2.t --- a/h2.t +++ b/h2.t @@ -32,7 +32,7 @@ plan(skip_all => 'IO::Socket::SSL too ol my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/) ->has(qw/limit_conn rewrite realip shmem/) - ->has_daemon('openssl')->plan(202); + ->has_daemon('openssl')->plan(211); # FreeBSD has a bug in not treating zero iovcnt as EINVAL @@ -105,6 +105,15 @@ http { location /h2 { return 200 $http2; } + location /sp { + return 200 $server_protocol; + } + location /scheme { + return 200 $scheme; + } + location /https { + return 200 $https; + } location /chunk_size { http2_chunk_size 1; return 200 'body'; @@ -676,6 +685,138 @@ is($frame->{data}, 'h2', 'http variable } +# $server_protocol + +TODO: { +local $TODO = 'not yet'; + +$sess = new_session(); +$sid = new_stream($sess, { path => '/sp' }); +$frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); + +($frame) = grep { $_->{type} eq "DATA" } @$frames; +is($frame->{data}, 'HTTP/2.0', 'server_protocol variable'); + +} + +# $server_protocol - SSL/TLS connection, NPN + +SKIP: { +eval { IO::Socket::SSL->can_npn() or die; }; +skip 'OpenSSL NPN support required', 1 if $@; + +TODO: { +local $TODO = 'not yet'; + +$sess = new_session(8084, SSL => 1, npn => 'h2'); +$sid = new_stream($sess, { path => '/sp' }); +$frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); + +($frame) = grep { $_->{type} eq "DATA" } @$frames; +is($frame->{data}, 'HTTP/2.0', 'server_protocol variable - npn'); + +} + +} + +# $server_protocol - SSL/TLS connection, ALPN + +SKIP: { +eval { IO::Socket::SSL->can_alpn() or die; }; +skip 'OpenSSL ALPN support required', 1 if $@; + +TODO: { +local $TODO = 'not yet'; + +$sess = new_session(8084, SSL => 1, alpn => 'h2'); +$sid = new_stream($sess, { path => '/sp' }); +$frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); + +($frame) = grep { $_->{type} eq "DATA" } @$frames; +is($frame->{data}, 'HTTP/2.0', 'server_protocol variable - alpn'); + +} + +} + +# $scheme + +$sess = new_session(); +$sid = new_stream($sess, { path => '/scheme' }); +$frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); + +($frame) = grep { $_->{type} eq "DATA" } @$frames; +is($frame->{data}, 'http', 'scheme variable'); + +# $scheme - SSL/TLS connection, NPN + +SKIP: { +eval { IO::Socket::SSL->can_npn() or die; }; +skip 'OpenSSL NPN support required', 1 if $@; + +$sess = new_session(8084, SSL => 1, npn => 'h2'); +$sid = new_stream($sess, { path => '/scheme' }); +$frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); + +($frame) = grep { $_->{type} eq "DATA" } @$frames; +is($frame->{data}, 'https', 'scheme variable - npn'); + +} + +# $scheme - SSL/TLS connection, ALPN + +SKIP: { +eval { IO::Socket::SSL->can_alpn() or die; }; +skip 'OpenSSL ALPN support required', 1 if $@; + +$sess = new_session(8084, SSL => 1, alpn => 'h2'); +$sid = new_stream($sess, { path => '/scheme' }); +$frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); + +($frame) = grep { $_->{type} eq "DATA" } @$frames; +is($frame->{data}, 'https', 'scheme variable - alpn'); + +} + +# $https + +$sess = new_session(); +$sid = new_stream($sess, { path => '/https' }); +$frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); + +($frame) = grep { $_->{type} eq "DATA" } @$frames; +is($frame->{data}, '', 'https variable'); + +# $https - SSL/TLS connection, NPN + +SKIP: { +eval { IO::Socket::SSL->can_npn() or die; }; +skip 'OpenSSL NPN support required', 1 if $@; + +$sess = new_session(8084, SSL => 1, npn => 'h2'); +$sid = new_stream($sess, { path => '/https' }); +$frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); + +($frame) = grep { $_->{type} eq "DATA" } @$frames; +is($frame->{data}, 'on', 'https variable - npn'); + +} + +# $https - SSL/TLS connection, ALPN + +SKIP: { +eval { IO::Socket::SSL->can_alpn() or die; }; +skip 'OpenSSL ALPN support required', 1 if $@; + +$sess = new_session(8084, SSL => 1, alpn => 'h2'); +$sid = new_stream($sess, { path => '/https' }); +$frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); + +($frame) = grep { $_->{type} eq "DATA" } @$frames; +is($frame->{data}, 'on', 'https variable - alpn'); + +} + # http2_chunk_size=1 $sess = new_session();