comparison h2.t @ 716:e3fd2c8d257e

Tests: added HTTP/2 tests for some http core module variables.
author Sergey Kandaurov <pluknet@nginx.com>
date Sat, 26 Sep 2015 00:03:22 +0300
parents 9ee52e137f3d
children 3b6ff3b7367d
comparison
equal deleted inserted replaced
715:9ee52e137f3d 716:e3fd2c8d257e
30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; 30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); };
31 plan(skip_all => 'IO::Socket::SSL too old') if $@; 31 plan(skip_all => 'IO::Socket::SSL too old') if $@;
32 32
33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/) 33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/)
34 ->has(qw/limit_conn rewrite realip shmem/) 34 ->has(qw/limit_conn rewrite realip shmem/)
35 ->has_daemon('openssl')->plan(202); 35 ->has_daemon('openssl')->plan(211);
36 36
37 # FreeBSD has a bug in not treating zero iovcnt as EINVAL 37 # FreeBSD has a bug in not treating zero iovcnt as EINVAL
38 38
39 $t->todo_alerts() unless $^O eq 'freebsd'; 39 $t->todo_alerts() unless $^O eq 'freebsd';
40 40
102 alias %%TESTDIR%%/t2.html; 102 alias %%TESTDIR%%/t2.html;
103 add_header X-PP $remote_addr; 103 add_header X-PP $remote_addr;
104 } 104 }
105 location /h2 { 105 location /h2 {
106 return 200 $http2; 106 return 200 $http2;
107 }
108 location /sp {
109 return 200 $server_protocol;
110 }
111 location /scheme {
112 return 200 $scheme;
113 }
114 location /https {
115 return 200 $https;
107 } 116 }
108 location /chunk_size { 117 location /chunk_size {
109 http2_chunk_size 1; 118 http2_chunk_size 1;
110 return 200 'body'; 119 return 200 'body';
111 } 120 }
671 $sid = new_stream($sess, { path => '/h2' }); 680 $sid = new_stream($sess, { path => '/h2' });
672 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); 681 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
673 682
674 ($frame) = grep { $_->{type} eq "DATA" } @$frames; 683 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
675 is($frame->{data}, 'h2', 'http variable - alpn'); 684 is($frame->{data}, 'h2', 'http variable - alpn');
685
686 }
687
688 # $server_protocol
689
690 TODO: {
691 local $TODO = 'not yet';
692
693 $sess = new_session();
694 $sid = new_stream($sess, { path => '/sp' });
695 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
696
697 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
698 is($frame->{data}, 'HTTP/2.0', 'server_protocol variable');
699
700 }
701
702 # $server_protocol - SSL/TLS connection, NPN
703
704 SKIP: {
705 eval { IO::Socket::SSL->can_npn() or die; };
706 skip 'OpenSSL NPN support required', 1 if $@;
707
708 TODO: {
709 local $TODO = 'not yet';
710
711 $sess = new_session(8084, SSL => 1, npn => 'h2');
712 $sid = new_stream($sess, { path => '/sp' });
713 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
714
715 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
716 is($frame->{data}, 'HTTP/2.0', 'server_protocol variable - npn');
717
718 }
719
720 }
721
722 # $server_protocol - SSL/TLS connection, ALPN
723
724 SKIP: {
725 eval { IO::Socket::SSL->can_alpn() or die; };
726 skip 'OpenSSL ALPN support required', 1 if $@;
727
728 TODO: {
729 local $TODO = 'not yet';
730
731 $sess = new_session(8084, SSL => 1, alpn => 'h2');
732 $sid = new_stream($sess, { path => '/sp' });
733 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
734
735 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
736 is($frame->{data}, 'HTTP/2.0', 'server_protocol variable - alpn');
737
738 }
739
740 }
741
742 # $scheme
743
744 $sess = new_session();
745 $sid = new_stream($sess, { path => '/scheme' });
746 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
747
748 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
749 is($frame->{data}, 'http', 'scheme variable');
750
751 # $scheme - SSL/TLS connection, NPN
752
753 SKIP: {
754 eval { IO::Socket::SSL->can_npn() or die; };
755 skip 'OpenSSL NPN support required', 1 if $@;
756
757 $sess = new_session(8084, SSL => 1, npn => 'h2');
758 $sid = new_stream($sess, { path => '/scheme' });
759 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
760
761 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
762 is($frame->{data}, 'https', 'scheme variable - npn');
763
764 }
765
766 # $scheme - SSL/TLS connection, ALPN
767
768 SKIP: {
769 eval { IO::Socket::SSL->can_alpn() or die; };
770 skip 'OpenSSL ALPN support required', 1 if $@;
771
772 $sess = new_session(8084, SSL => 1, alpn => 'h2');
773 $sid = new_stream($sess, { path => '/scheme' });
774 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
775
776 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
777 is($frame->{data}, 'https', 'scheme variable - alpn');
778
779 }
780
781 # $https
782
783 $sess = new_session();
784 $sid = new_stream($sess, { path => '/https' });
785 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
786
787 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
788 is($frame->{data}, '', 'https variable');
789
790 # $https - SSL/TLS connection, NPN
791
792 SKIP: {
793 eval { IO::Socket::SSL->can_npn() or die; };
794 skip 'OpenSSL NPN support required', 1 if $@;
795
796 $sess = new_session(8084, SSL => 1, npn => 'h2');
797 $sid = new_stream($sess, { path => '/https' });
798 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
799
800 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
801 is($frame->{data}, 'on', 'https variable - npn');
802
803 }
804
805 # $https - SSL/TLS connection, ALPN
806
807 SKIP: {
808 eval { IO::Socket::SSL->can_alpn() or die; };
809 skip 'OpenSSL ALPN support required', 1 if $@;
810
811 $sess = new_session(8084, SSL => 1, alpn => 'h2');
812 $sid = new_stream($sess, { path => '/https' });
813 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
814
815 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
816 is($frame->{data}, 'on', 'https variable - alpn');
676 817
677 } 818 }
678 819
679 # http2_chunk_size=1 820 # http2_chunk_size=1
680 821