comparison h2.t @ 849:cebd29c253ea

Tests: added HTTP/2 positive test for huffman encoding.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 08 Feb 2016 13:22:02 +0300
parents 40ad07634a5e
children 2b1d0f6c9d41
comparison
equal deleted inserted replaced
848:40ad07634a5e 849:cebd29c253ea
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(310); 35 ->has_daemon('openssl')->plan(312);
36 36
37 # Some systems may have also a bug in not treating zero writev iovcnt as EINVAL 37 # Some systems may have also a bug in not treating zero writev iovcnt as EINVAL
38 38
39 $t->todo_alerts(); 39 $t->todo_alerts();
40 40
744 744
745 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; 745 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
746 is($frame->{headers}->{'x-sent-foo'}, 'X-Baz', 746 is($frame->{headers}->{'x-sent-foo'}, 'X-Baz',
747 'name with indexing - indexed name'); 747 'name with indexing - indexed name');
748 748
749 # header field with characters not suitable for huffman encoding 749 # response header field with characters not suitable for huffman encoding
750 750
751 $sess = new_session(); 751 $sess = new_session();
752 $sid = new_stream($sess, { headers => [ 752 $sid = new_stream($sess, { headers => [
753 { name => ':method', value => 'GET', mode => 0 }, 753 { name => ':method', value => 'GET', mode => 0 },
754 { name => ':scheme', value => 'http', mode => 0 }, 754 { name => ':scheme', value => 'http', mode => 0 },
758 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); 758 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
759 759
760 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; 760 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
761 is($frame->{headers}->{'x-sent-foo'}, '{{{{{', 'rare chars'); 761 is($frame->{headers}->{'x-sent-foo'}, '{{{{{', 'rare chars');
762 like($sess->{headers}, qr/\Q{{{{{/, 'rare chars - no huffman encoding'); 762 like($sess->{headers}, qr/\Q{{{{{/, 'rare chars - no huffman encoding');
763
764 # response header field with huffman encoding
765 # NB: implementation detail, not obligated
766
767 $sess = new_session();
768 $sid = new_stream($sess, { headers => [
769 { name => ':method', value => 'GET', mode => 0 },
770 { name => ':scheme', value => 'http', mode => 0 },
771 { name => ':path', value => '/', mode => 0 },
772 { name => ':authority', value => 'localhost', mode => 1 },
773 { name => 'x-foo', value => 'aaaaa', mode => 2 }]});
774 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
775
776 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
777 is($frame->{headers}->{'x-sent-foo'}, 'aaaaa', 'well known chars');
778
779 TODO: {
780 local $TODO = 'not yet';
781
782 unlike($sess->{headers}, qr/aaaaa/, 'well known chars - huffman encoding');
783
784 }
763 785
764 # 6.3. Dynamic Table Size Update 786 # 6.3. Dynamic Table Size Update
765 787
766 # remove some indexed headers from the dynamic table 788 # remove some indexed headers from the dynamic table
767 # by maintaining dynamic table space only for index 0 789 # by maintaining dynamic table space only for index 0